This tutorial demonstrates how to make a simple interchain call using the accounts.md to a pre-deployed TestRecipient
contract on a remote chain.
You can also check out the hyperlane-quickstart
repo for running this out of the box.
{% hint style="info" %} Want to learn more about interchain accounts? Take a look at the accounts.md documentation {% endhint %}
$DESTINATION_DOMAIN
: The domain ID of the destination chain. See domains$RECIPIENT
: The address of theTestRecipient
contract on the destination chain,0x36FdA966CfffF8a9Cdc814f546db0e6378bFef35
$CALLDATA
: The calldata of the call to make onTestRecipient
, which we generate usingcast
:0xf07c1f4700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001648656c6c6f576f726c642066726f6d20616e2049434100000000000000000000
$ cast calldata "fooBar(uint256,string)" 1 "HelloWorld from an ICA"
Sending a message is a simple matter of calling InterchainAccountRouter.callRemote()
. This function can be called easily using Etherscan+Metamask or cast.
{% tabs %} {% tab title="Using Metamask" %}
- Navigate to the
InterchainAccountRouter
contract page on Etherscan (or whatever chain you want to send from). See addresses forInterchainAccountRouter
addresses - Under the
Contract
tab, find theWrite as Proxy
button. - Click on the
Connect to Web3
button to connect your Wallet (i.e. Metamask). Make sure that you are on the correct network. - Expand the
callRemote
box - For destination domain, enter
$DESTINATION_DOMAIN
. You could use137
to send to mainnet Polygon, or see other domains - For the
_to
argument, enter the$RECIPIENT
- For the
_value
argument, enter 0 - For the
_data
argument, enter the$CALLDATA
- Submit the transaction via your wallet/Metamask {% endtab %}
{% tab title="Using cast" %}
You can call the InterchainAccountRouter
directly using cast
. Make sure that you have a valid RPC URL for the origin chain and a private key with which you can pay for gas.
cast send 0xE0Be420779cAd6E2bEA1E4F7C02F996D9ED1fCB5 \
'callRemote(uint32,address,uint256,bytes)' \
$DESTINATION_DOMAIN $RECIPIENT 0 $CALLDATA \
--rpc-url $RPC_URL --private-key $PRIVATE_KEY
{% endtab %} {% endtabs %}
If you view the transaction on a block explorer, you should be able to see the Dispatch
event. You can see an example message sending transaction here.
{% hint style="warning" %}
For your call to be executed on the destination chain, you must manually-pay-for-interchain-gas.md, using 550000
for the gas amount
{% endhint %}
{% content-ref url="../guides/manually-pay-for-interchain-gas.md" %} manually-pay-for-interchain-gas.md {% endcontent-ref %}