InterchainGasPaymaster contract will revert if payment is insufficient to cover the relayer’s anticipated costs. The gas quote calculated at dispatch time must align with the relayer’s anticipated costs.
Gas Limit
ThegasLimit is set based on the cost of calling handle on the destination chain for a given message. This can vary depending on message content and the logic of the handler.
The default gasLimit for metering the handle call is a static default of 50_000 gas. This is sufficient for simple operations but may not be enough for more complex handle functions.
If your handle function performs complex operations or requires more gas, you must override the default gasLimit in metadata to avoid transaction reverts. Benchmark your handle implementations in unit tests to determine a reasonable gasLimit to use.
Metadata
This hook expects metadata in a packed encoding ofStandardHookMetadata. See the Mailbox dispatch overloads for how to pass metadata overrides.
StandardHookMetadata struct defines the fields required for metadata encoding:
variant: Specifies the metadata format version.msgValue: Amount of native token sent with the message.gasLimit: Gas limit for thehandlefunction on the destination chain. Ensure this matches your simulation results.refundAddress: Address to refund unused gas payments.
StandardHookMetadata.formatMetadata library function. Direct encoding of the struct with abi.encodePacked is not supported in Solidity.
Example Usage
Determine and Override the Gas Limit
- Simulate and Benchmark Gas Usage:
- Use tools like Tenderly or Foundry to simulate the
handlefunction on your message recipient. Ensure thefromaddress is set to the Mailbox contract on your chain. - If gas usage exceeds
50,000gas, calculate an appropriategasLimitand update your metadata. - Use the call-to-action in the Hyperlane Explorer to simulate transactions from the message details.
- Update Your Metadata:
- Calculate the required
gasLimitbased on the simulation. - Pass the updated
gasLimitin your metadata to ensure the relayer will deliver your message.
Destination Gas Config
For each remote domain, the InterchainGasPaymaster sets the domain gas config.Gas overhead
The gas overhead is set as part of the destination gas configuration. This corresponds to the operational cost of processing a message on the destination chain.- You should ensure the
gasOverheadsufficiently covers the range of ISMs on your destination chain. - As you can configure different ISMs for different message types, you may have different gas overheads for each ISM’sverifyfunction.
Gas Oracles
Interchain Gas Payment requirements are calculated using oraclized gas prices and exchange rates between the origin and destination chains. IGP contracts may be configured with gas oracles, which are responsible for tracking remote token gas prices and exchange rates. Developers should use thequoteDispatch function on the Mailbox contract to calculate gas fees. The quoteDispatch accounts for system-level overhead and ensures accurate fee calculation for the entire dispatch process.
Exchange rates and gas prices are up to the relayer to decide. A spread may be
charged to account for drift and operating costs.
getExchangeRateAndGasPrice
destinationDomain: The message’s destination domain
tokenExchangeRate: The exchange rate between the origin and destination chain’s gas tokensgasPrice: The gas price for the destination chain
quoteGasPayment
The quoteGasPayment function calculates fees for the relayer’s anticipated costs.
destinationDomain: The message’s destination domaingasLimit: The gas limit to meter thehandlecall with
fee: The payment required for thepostDispatchto succeed
The
quoteGasPayment gives an estimated fee based on the destinationDomain and gasLimit. However, it does not include extra gas costs added by the Interchain Gas Paymaster (IGP) for the Default ISM payment.To get the full fee, use quoteDispatch() from the Mailbox contract. It provides a complete quote that includes these additional costs.👉 See Quote Dispatch for more details.Retrying
If thehandle call consumes more gas than quoted, the relayer will not submit a process transaction. This issue often occurs due to insufficient gas payment during the initial dispatch.
In this case, additional gas can be paid for with the payForGas function.
messageId: The message identifier returned fromdispatchcalldestinationDomain: The message’s destination domaingasAmount: The additional gas amount to pay forrefundAddress: The address to refund excess payment to
Using the Hyperlane Explorer for Debugging
The Hyperlane Explorer is a powerful tool to debug cross-chain message issues, including gas payments and relayer behavior.Key Features
- Message Status: View the current status of your message (e.g., “Retry: GasPaymentRequirementNotMet”).
- Gas Payment Details: Check the gas amount paid (Origin IGP gas amount) and the amount required by the relayer.
- Simulate Calldata: Use the “View calldata details” option to simulate transactions on tools like Tenderly.
Troubleshooting
This section covers common issues developers encounter with Interchain Gas Payments, along with potential solutions.GasPaymentRequirementNotMet Warning
-
Reason: This occurs when the gas payment provided during
dispatchdoes not meet the relayer’s calculated requirement. -
Solution:
- Use
quoteDispatchto calculate the aggregate fee required for adispatchcall to be successful. - Verify that
msg.valuein your metadata covers the relayer’s quoted fee. - Check the message status in the Hyperlane Explorer. Look for:
Retry(GasPaymentRequirementNotMet).
- Use
Fallback Routing and Overpayment Warning
-
Reason:
msg.valueexceeds the required gas payment, triggering the fallback routing hook. -
Solution:
- Verify that your quoting logic (
quoteDispatch) matches the relayer’s anticipated fees. - Avoid overestimating
gasLimitvalues without first benchmarking thehandlefunction. - Simulate the transaction to confirm appropriate payment.
- Verify that your quoting logic (
Unexpectedly Large Gas Quotes
-
Reason: A very high
gasLimitwas set, leading to excessively large gas quotes. -
Solution:
- Double-check the
gasLimitspecified in your metadata. - Verify that your quoting logic (
quoteDispatch) matches the relayer’s anticipated fees. - Adjust the
gasLimitto match the estimated gas consumption of yourhandlefunction.
- Double-check the