description |
---|
Manually pay a relayer to deliver messages |
{% hint style="info" %} Read up on interchain-gas-payments.md and the interchain-gas-paymaster-api.md {% endhint %}
This guide will show you how to make a manual gas payment.
Typically, the smart contract that sent the interchain message will paying-for-interchain-gas.md.
In some cases (e.g. quickstarts) it may be useful to make gas payments manually.
To make a manual gas payment, you will need
- The
$MESSAGE_ID
of the interchain message you are paying for - The
$DESTINATION_DOMAIN
of the interchain message you are paying for - The
$GAS_AMOUNT
that you need in order to deliver your message on the destination chain
If you have the hash of the transaction that sent your interchain message, you can use a block explorer to find the message ID. Navigate to the transaction in a block explorer, open the "Logs" tab, and find the DispatchId
log. The "Topic 1" is your message ID. Use the dropdown to select "Hex", and use this value. For example:
Finding the message ID from the DispatchId
log
{% tabs %} {% tab title="Using Metamask" %} Getting the interchain gas payment quote
- Navigate to the #defaultisminterchaingaspaymaster contract page on Etherscan (or its equivalent if you're sending from a non-Ethereum chain).
- Under the
Contract
tab, selectRead Contract
. - Expand the
quoteGasPayment
function. - For destination domain, enter
$DESTINATION_DOMAIN
. - For gas amount, enter
$GAS_AMOUNT
. - Click
Query
and make note of the amount returned as$GAS_PAYMENT_QUOTE
. For example, at the time of writing, the quote is1
wei.
Make the interchain gas payment
-
Still on the
DefaultIsmInterchainGasPaymaster
contract page on Etherscan, selectWrite Contract
. -
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
payForGas
function. -
For the payable amount, Etherscan expects an amount quoted in ether, while our
$GAS_PAYMENT_QUOTE
is in wei. To convert from wei to ether, input the amount$GAS_PAYMENT_QUOTE
, which is in wei, into https://eth-converter.com/ and copy the ether amount. Use this ether amount as the payable amount. -
For the message ID, input your
$MESSAGE_ID
. -
For the destination domain, input your
$DESTINATION_DOMAIN
. -
For gas amount, enter
$GAS_AMOUNT
. -
For the refund address, input the address of the account you will sign the transaction with. This will receive a potential refund if you overpay for interchain gas.
-
Click "Write" and submit the transaction via your wallet/Metamask.
{% endtab %}
{% tab title="Using cast" %} Getting the interchain gas payment quote
First, get a quote for how much your gas payment will cost, and save this in an environment variable called $GAS_PAYMENT_QUOTE
:
{% code overflow="wrap" %}
cast call $IGP_ADDRESS "quoteGasPayment(uint32,uint256)" $DESTINATION_DOMAIN $GAS_AMOUNT --rpc-url $RPC_URL
{% endcode %}
Make the interchain gas payment
Now, we can call payGasFor
, and we supply the gas payment quote as value in the transaction. The final parameter, $MY_ADDRESS
, is the address of the account whose private key you're signing with. This address will be refunded any overpayment.
cast send $IGP_ADDRESS "payForGas(bytes32,uint32,uint256,address)" $MESSAGE_ID $DESTINATION_DOMAIN $GAS_AMOUNT $MY_ADDRESS --rpc-url $RPC_URL
--private-key $PRIVATE_KEY --value $GAS_PAYMENT_QUOTE
{% endtab %} {% endtabs %}
After you've paid for interchain gas, you should be able to see a corresponding transaction delivering your message on the destination chain. You can watch for this transaction on Hyperlane's Message Explorer by entering the transaction hash or the sender/recipient address in the input field.
You can see an example message delivery transaction here.
This transaction sent a "Hello World" message from Goerli to Alfajores
{% hint style="warning" %} Message not delivered? See observability.md for tips and tricks {% endhint %}