MockAxelarGasService
Inherits: InterchainGasEstimation, Upgradable, IAxelarGasService
Title: AxelarGasService
This contract manages gas payments and refunds for cross-chain communication on the Axelar network.
The owner address of this contract should be the microservice that pays for gas.
Users pay gas for cross-chain calls, and the gasCollector can collect accumulated fees and/or refund users if needed.
State Variables
gasCollector
address public immutable gasCollector
Functions
constructor
Constructs the AxelarGasService contract.
constructor(address gasCollector_) ;
Parameters
| Name | Type | Description |
|---|---|---|
gasCollector_ | address | The address of the gas collector |
_setup
function _setup(bytes calldata data) internal override;
onlyCollector
Modifier that ensures the caller is the designated gas collector.
modifier onlyCollector() ;
payGas
Pay for gas for any type of contract execution on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
If estimateOnChain is true, the function will estimate the gas cost and revert if the payment is insufficient.
function payGas(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
uint256 executionGasLimit,
bool estimateOnChain,
address refundAddress,
bytes calldata params
) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call |
executionGasLimit | uint256 | The gas limit for the contract call |
estimateOnChain | bool | Flag to enable on-chain gas estimation |
refundAddress | address | The address where refunds, if any, should be sent |
params | bytes | Additional parameters for gas payment |
payGasForContractCall
Pay for gas using ERC20 tokens for a contract call on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
function payGasForContractCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call |
gasToken | address | The address of the ERC20 token used to pay for gas |
gasFeeAmount | uint256 | The amount of tokens to pay for gas |
refundAddress | address | The address where refunds, if any, should be sent |
payGasForContractCallWithToken
Pay for gas using ERC20 tokens for a contract call with tokens on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
function payGasForContractCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string memory symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call with tokens will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call with tokens |
symbol | string | The symbol of the token to be sent with the call |
amount | uint256 | The amount of tokens to be sent with the call |
gasToken | address | The address of the ERC20 token used to pay for gas |
gasFeeAmount | uint256 | The amount of tokens to pay for gas |
refundAddress | address | The address where refunds, if any, should be sent |
payNativeGasForContractCall
Pay for gas using native currency for a contract call on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForContractCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address refundAddress
) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call |
refundAddress | address | The address where refunds, if any, should be sent |
payNativeGasForContractCallWithToken
Pay for gas using native currency for a contract call with tokens on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForContractCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address refundAddress
) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call with tokens will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call with tokens |
symbol | string | The symbol of the token to be sent with the call |
amount | uint256 | The amount of tokens to be sent with the call |
refundAddress | address | The address where refunds, if any, should be sent |
payGasForExpressCall
Pay for gas using ERC20 tokens for an express contract call on a destination chain.
This function is called on the source chain before calling the gateway to express execute a remote contract.
function payGasForExpressCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call |
gasToken | address | The address of the ERC20 token used to pay for gas |
gasFeeAmount | uint256 | The amount of tokens to pay for gas |
refundAddress | address | The address where refunds, if any, should be sent |
payGasForExpressCallWithToken
Pay for gas using ERC20 tokens for an express contract call with tokens on a destination chain.
This function is called on the source chain before calling the gateway to express execute a remote contract.
function payGasForExpressCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string memory symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call with tokens will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call with tokens |
symbol | string | The symbol of the token to be sent with the call |
amount | uint256 | The amount of tokens to be sent with the call |
gasToken | address | The address of the ERC20 token used to pay for gas |
gasFeeAmount | uint256 | The amount of tokens to pay for gas |
refundAddress | address | The address where refunds, if any, should be sent |
payNativeGasForExpressCall
Pay for gas using native currency for an express contract call on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForExpressCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address refundAddress
) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call |
refundAddress | address | The address where refunds, if any, should be sent |
payNativeGasForExpressCallWithToken
Pay for gas using native currency for an express contract call with tokens on a destination chain.
This function is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForExpressCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address refundAddress
) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address making the payment |
destinationChain | string | The target chain where the contract call with tokens will be made |
destinationAddress | string | The target address on the destination chain |
payload | bytes | Data payload for the contract call with tokens |
symbol | string | The symbol of the token to be sent with the call |
amount | uint256 | The amount of tokens to be sent with the call |
refundAddress | address | The address where refunds, if any, should be sent |
addGas
Add additional gas payment using ERC20 tokens after initiating a cross-chain call.
This function can be called on the source chain after calling the gateway to execute a remote contract.
function addGas(bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress)
external
override;
Parameters
| Name | Type | Description |
|---|---|---|
txHash | bytes32 | The transaction hash of the cross-chain call |
logIndex | uint256 | The log index for the cross-chain call |
gasToken | address | The ERC20 token address used to add gas |
gasFeeAmount | uint256 | The amount of tokens to add as gas |
refundAddress | address | The address where refunds, if any, should be sent |
addNativeGas
Add additional gas payment using native currency after initiating a cross-chain call.
This function can be called on the source chain after calling the gateway to execute a remote contract.
function addNativeGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
txHash | bytes32 | The transaction hash of the cross-chain call |
logIndex | uint256 | The log index for the cross-chain call |
refundAddress | address | The address where refunds, if any, should be sent |
addExpressGas
Add additional gas payment using ERC20 tokens after initiating an express cross-chain call.
This function can be called on the source chain after calling the gateway to express execute a remote contract.
function addExpressGas(
bytes32 txHash,
uint256 logIndex,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external override;
Parameters
| Name | Type | Description |
|---|---|---|
txHash | bytes32 | The transaction hash of the cross-chain call |
logIndex | uint256 | The log index for the cross-chain call |
gasToken | address | The ERC20 token address used to add gas |
gasFeeAmount | uint256 | The amount of tokens to add as gas |
refundAddress | address | The address where refunds, if any, should be sent |
addNativeExpressGas
Add additional gas payment using native currency after initiating an express cross-chain call.
This function can be called on the source chain after calling the gateway to express execute a remote contract.
function addNativeExpressGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable override;
Parameters
| Name | Type | Description |
|---|---|---|
txHash | bytes32 | The transaction hash of the cross-chain call |
logIndex | uint256 | The log index for the cross-chain call |
refundAddress | address | The address where refunds, if any, should be sent |
updateGasInfo
Updates the gas price for a specific chain.
This function is called by the gas oracle to update the gas prices for a specific chains.
function updateGasInfo(string[] calldata chains, GasInfo[] calldata gasUpdates) external onlyCollector;
Parameters
| Name | Type | Description |
|---|---|---|
chains | string[] | Array of chain names |
gasUpdates | GasInfo[] | Array of gas updates |
collectFees
Allows the gasCollector to collect accumulated fees from the contract.
Use address(0) as the token address for native currency.
function collectFees(address payable receiver, address[] calldata tokens, uint256[] calldata amounts)
external
onlyCollector;
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address payable | The address to receive the collected fees |
tokens | address[] | Array of token addresses to be collected |
amounts | uint256[] | Array of amounts to be collected for each respective token address |
refund
Deprecated refund function, kept for backward compatibility.
function refund(address payable receiver, address token, uint256 amount) external onlyCollector;
refund
Refunds gas payment to the receiver in relation to a specific cross-chain transaction.
Only callable by the gasCollector.
Use address(0) as the token address to refund native currency.
function refund(bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount)
external
onlyCollector;
Parameters
| Name | Type | Description |
|---|---|---|
txHash | bytes32 | The transaction hash of the cross-chain call |
logIndex | uint256 | The log index for the cross-chain call |
receiver | address payable | The address to receive the refund |
token | address | The token address to be refunded |
amount | uint256 | The amount to refund |
_refund
Internal function to implement gas refund logic.
function _refund(bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount)
private;
contractId
Returns a unique identifier for the contract.
function contractId() external pure returns (bytes32);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | bytes32 Hash of the contract identifier |