Solidity API
InterchainGasEstimation
This is an abstract contract that allows for estimating gas fees for cross-chain communication on the Axelar network.
GAS_SERVICE_SLOT
TX_ENCODING_OVERHEAD
uint256 TX_ENCODING_OVERHEAD
GMP_CALLDATA_SIZE
uint256 GMP_CALLDATA_SIZE
GasServiceStorage
struct GasServiceStorage {
mapping(string => struct GasInfo) gasPrices;
}
getGasInfo
function getGasInfo(string chain) external view returns (struct GasInfo)
Returns the gas price for a specific chain.
Parameters
Name |
Type |
Description |
chain |
string |
The name of the chain |
Return Values
Name |
Type |
Description |
[0] |
struct GasInfo |
gasInfo The gas info for the chain |
_setGasInfo
function _setGasInfo(string chain, struct GasInfo gasInfo) internal
Sets the gas price for a specific chain.
This function is called by the gas oracle to update the gas price for a specific chain.
Parameters
Name |
Type |
Description |
chain |
string |
The name of the chain |
gasInfo |
struct GasInfo |
The gas info for the chain |
estimateGasFee
function estimateGasFee(string destinationChain, string, bytes payload, uint256 executionGasLimit, bytes) public view returns (uint256 gasEstimate)
Estimates the gas fee for a contract call on a destination chain.
Parameters
Name |
Type |
Description |
destinationChain |
string |
Axelar registered name of the destination chain param destinationAddress Destination contract address being called |
|
string |
|
payload |
bytes |
|
executionGasLimit |
uint256 |
The gas limit to be used for the destination contract execution, e.g. pass in 200k if your app consumes needs upto 200k for this contract call param params Additional parameters for the gas estimation |
|
bytes |
|
Return Values
Name |
Type |
Description |
gasEstimate |
uint256 |
The cross-chain gas estimate, in terms of source chain’s native gas token that should be forwarded to the gas service. |
computeL1DataFee
function computeL1DataFee(enum GasEstimationType gasEstimationType, bytes payload, struct GasInfo gasInfo, struct GasInfo l1GasInfo) internal view returns (uint256)
Computes the additional L1 data fee for an L2 destination chain.
Parameters
Name |
Type |
Description |
gasEstimationType |
enum GasEstimationType |
The gas estimation type |
payload |
bytes |
The payload of the contract call |
gasInfo |
struct GasInfo |
|
l1GasInfo |
struct GasInfo |
The L1 gas info |
Return Values
Name |
Type |
Description |
[0] |
uint256 |
l1DataFee The L1 to L2 data fee |
optimismEcotoneL1Fee
function optimismEcotoneL1Fee(bytes payload, struct GasInfo gasInfo, struct GasInfo l1GasInfo) internal view returns (uint256 l1DataFee)
Computes the L1 to L2 fee for an OP chain with Ecotone gas model.
Parameters
Name |
Type |
Description |
payload |
bytes |
The payload of the contract call |
gasInfo |
struct GasInfo |
Destination chain gas info |
l1GasInfo |
struct GasInfo |
The L1 gas info |
Return Values
Name |
Type |
Description |
l1DataFee |
uint256 |
The L1 to L2 data fee |
optimismBedrockL1Fee
function optimismBedrockL1Fee(bytes payload, struct GasInfo gasInfo, struct GasInfo l1GasInfo) internal view returns (uint256 l1DataFee)
Computes the L1 to L2 fee for an OP chain with Bedrock gas model.
Parameters
Name |
Type |
Description |
payload |
bytes |
The payload of the contract call |
gasInfo |
struct GasInfo |
Destination chain gas info |
l1GasInfo |
struct GasInfo |
The L1 gas info |
Return Values
Name |
Type |
Description |
l1DataFee |
uint256 |
The L1 to L2 data fee |
arbitrumL1Fee
function arbitrumL1Fee(bytes payload, struct GasInfo, struct GasInfo l1GasInfo) internal view returns (uint256 l1DataFee)
Computes the L1 to L2 fee for a contract call on the Arbitrum chain.
Parameters
Name |
Type |
Description |
payload |
bytes |
The payload of the contract call param gasInfo Destination chain gas info |
|
struct GasInfo |
|
l1GasInfo |
struct GasInfo |
The L1 gas info |
Return Values
Name |
Type |
Description |
l1DataFee |
uint256 |
The L1 to L2 data fee |
function scrollL1Fee(bytes payload, struct GasInfo gasInfo, struct GasInfo l1GasInfo) internal view returns (uint256 l1DataFee)
Computes the L1 to L2 fee for a contract call on the Scroll chain.
Parameters
Name |
Type |
Description |
payload |
bytes |
The payload of the contract call |
gasInfo |
struct GasInfo |
Destination chain gas info |
l1GasInfo |
struct GasInfo |
The L1 gas info |
Return Values
Name |
Type |
Description |
l1DataFee |
uint256 |
The L1 to L2 data fee |