Liquidity Layer
Send value across chains with Hyperlane's Liquidity Layer.
The LiquidityLayer API is in beta. The API is subject to change
This tutorial demonstrates how to:
- Send a simple interchain message alongside with tokens to a pre-deployed
TestTokenRecipient
contract. We are using Circle's CCTP to facilitative the native token transfer of USDC.
$DESTINATION_DOMAIN
: The domain ID of the destination chain. Domain IDs can be found here. Goerli's domain ID is5
, Fuji is43113
$RECIPIENT
: The address of theTestTokenRecipient
contract on the destination chain padded to bytes32,0x00000000000000000000000085ac1164878e017b67660a74ff1f41f3D05C02Bb
on every chain.$TOKEN_ADDRESS
: The address of the Token you want to transfer. On Goerli, USDC is at0x07865c6e87b9f70255377e024ace6630c1eaa37f
. On Fuji, USDC is at0x5425890298aed601595a70ab815c96711a31bc65
. On Ethereum, USDC is at0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
. On Avalanche, USDC is at0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
For transferring USDC via the CCTP on testnet, you can use https://usdcfaucet.com/. For mainnet, acquire USDC on your favorite CEX or DEX.
Using Metamask
Using Cast
Approve USDC to the Liquidity Layer
- 1.
- 2.Under the
Contract
tab, find theWrite as Proxy
button. - 3.Click on the
Connect to Web3
button to connect your Wallet (i.e. Metamask). Make sure that you are on the correct network. - 4.Expand the
approve
box. - 5.Approve the as the spender with the desirable amount (Note that USDC has 6 decimals vs. the conventional 18)
- 6.Submit the transaction via Metamask
Dispatch a Message With Tokens
- 1.
- 2.Under the
Contract
tab, find theWrite as Proxy
button. - 3.Click on the
Connect to Web3
button to connect your Wallet (i.e. Metamask). Make sure that you are on the correct network. - 4.Expand the
dispatchWithTokens
box. - 5.For destination domain, enter
$DESTINATION_DOMAIN
. - 6.For the recipient address, enter
$RECIPIENT
. - 7.For the message body, enter whatever you like! A string-to-hex converter website can help you write your message if you want to send a human-readable message. In the example below, we sent the "Hello World" string as
0x48656c6c6f20576f726c64
- 8.For the token, enter
$TOKEN_ADDRESS
- 9.For the amount, enter the desirable amount
- 10.For the bridge, enter the bridge name as a string (i.e.
Circle
orPortal
) - 11.Submit the transaction via your wallet/Metamask
You can call
LiquidityLayerRouter.dispatchWithTokens
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.The final two parameters are the amount of the token you wish to send (not accounting for token decimals), and the bridge you wish to use. You can use the
Circle
or Portal
bridges.This example shows how to send 1 USDC (USDC has 6 decimals, so
1000000
is one full USDC) via the Circle bridge.cast send $LIQUIDITY_LAYER_ROUTER "dispatchWithTokens(uint32,bytes32,bytes,address,uint256,string)" $DESTINATION_DOMAIN $RECIPIENT $(cast --from-utf8 "your message") $TOKEN_ADDRESS 1000000 Circle -rpc-url $RPC_URL
--private-key $PRIVATE_KEY
For your transfer to be executed on the destination chain, you must Manually pay for interchain gas, using
350000
for the gas amountLast modified 4mo ago