v2
Search
K

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:

Inputs

  • $LIQUIDITY_LAYER_ROUTER: The address of the LiquidityLayerRouter which you can find under here
  • $DESTINATION_DOMAIN: The domain ID of the destination chain. Domain IDs can be found here. Goerli's domain ID is 5, Fuji is 43113
  • $RECIPIENT: The address of the TestTokenRecipient 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 at 0x07865c6e87b9f70255377e024ace6630c1eaa37f. On Fuji, USDC is at 0x5425890298aed601595a70ab815c96711a31bc65. On Ethereum, USDC is at 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48. On Avalanche, USDC is at 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E

Acquire tokens

For transferring USDC via the CCTP on testnet, you can use https://usdcfaucet.com/. For mainnet, acquire USDC on your favorite CEX or DEX.

Send a message with tokens

Sending a message with tokens is a simple matter of calling LiquidityLayerRouter.dispatchWithTokens. This function can be called easily using Etherscan+Metamask or cast.
Using Metamask
Using Cast
Approve USDC to the Liquidity Layer
  1. 1.
    Navigate to the USDC token contract page on Etherscan
  2. 2.
    Under the Contract tab, find the Write as Proxy button.
  3. 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. 4.
    Expand the approve box.
  5. 5.
    Approve the as the spender with the desirable amount (Note that USDC has 6 decimals vs. the conventional 18)
  6. 6.
    Submit the transaction via Metamask
Dispatch a Message With Tokens
  1. 1.
    Navigate to the LiquidityLayerRouter contract page on Etherscan.
  2. 2.
    Under the Contract tab, find the Write as Proxy button.
  3. 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. 4.
    Expand the dispatchWithTokens box.
  5. 5.
    For destination domain, enter $DESTINATION_DOMAIN.
  6. 6.
    For the recipient address, enter $RECIPIENT.
  7. 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. 8.
    For the token, enter $TOKEN_ADDRESS
  9. 9.
    For the amount, enter the desirable amount
  10. 10.
    For the bridge, enter the bridge name as a string (i.e. Circle or Portal)
  11. 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 amount