在本地初始化及测试
git clone https://github.com/wormhole-foundation/hello-wormhole.git
cd hello-wormhole
在 package json 里有个 bug,修改
"typechain": "typechain --target ethers-v5 --out-dir ./ts-scripts/ethers-contracts ./out/**/*.json"
为
"typechain": "typechain --target ethers-v5 --out-dir ./ts-scripts/ethers-contracts ./out/**/*.sol/*.json"
npm run build
forge test
部署到测试网
EVM_PRIVATE_KEY=your_wallet_private_key npm run deploy
解析HelloWormhole跨链合约
在源链合约,你需要用这些代码来发送消息给 wormholeRelayer
wormholeRelayer.sendPayloadToEvm{value: cost}(
targetChain,
targetAddress,
payload,
0, // no receiver value needed
GAS_LIMIT
);
在目标链, wormhole 中继器将找到目标地址的智能合约并调用其 receiveWormholeMessages
方法来发送消息给目标链上的目标合约地址。
参考资料
https://docs.wormhole.com/wormhole/quick-start/tutorials/hello-wormhole