axelar-gmp-sdk-solidity

Solidity API

IAxelarGasService

This is an interface for the AxelarGasService contract which manages gas payments and refunds for cross-chain communication on the Axelar network.

This interface inherits IUpgradable

InvalidAddress

error InvalidAddress()

NotCollector

error NotCollector()

InvalidAmounts

error InvalidAmounts()

InvalidGasUpdates

error InvalidGasUpdates()

InvalidParams

error InvalidParams()

InsufficientGasPayment

error InsufficientGasPayment(uint256 required, uint256 provided)

GasPaidForContractCall

event GasPaidForContractCall(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, address gasToken, uint256 gasFeeAmount, address refundAddress)

GasPaidForContractCallWithToken

event GasPaidForContractCallWithToken(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, string symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress)

NativeGasPaidForContractCall

event NativeGasPaidForContractCall(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, uint256 gasFeeAmount, address refundAddress)

NativeGasPaidForContractCallWithToken

event NativeGasPaidForContractCallWithToken(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, string symbol, uint256 amount, uint256 gasFeeAmount, address refundAddress)

GasPaidForExpressCall

event GasPaidForExpressCall(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, address gasToken, uint256 gasFeeAmount, address refundAddress)

GasPaidForExpressCallWithToken

event GasPaidForExpressCallWithToken(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, string symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress)

NativeGasPaidForExpressCall

event NativeGasPaidForExpressCall(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, uint256 gasFeeAmount, address refundAddress)

NativeGasPaidForExpressCallWithToken

event NativeGasPaidForExpressCallWithToken(address sourceAddress, string destinationChain, string destinationAddress, bytes32 payloadHash, string symbol, uint256 amount, uint256 gasFeeAmount, address refundAddress)

GasAdded

event GasAdded(bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress)

NativeGasAdded

event NativeGasAdded(bytes32 txHash, uint256 logIndex, uint256 gasFeeAmount, address refundAddress)

ExpressGasAdded

event ExpressGasAdded(bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress)

NativeExpressGasAdded

event NativeExpressGasAdded(bytes32 txHash, uint256 logIndex, uint256 gasFeeAmount, address refundAddress)

Refunded

event Refunded(bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount)

payGas

function payGas(address sender, string destinationChain, string destinationAddress, bytes payload, uint256 executionGasLimit, bool estimateOnChain, address refundAddress, bytes params) external payable

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.

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. This can be left empty for normal contract call payments.

payGasForContractCall

function payGasForContractCall(address sender, string destinationChain, string destinationAddress, bytes payload, address gasToken, uint256 gasFeeAmount, address refundAddress) external

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.

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

function payGasForContractCallWithToken(address sender, string destinationChain, string destinationAddress, bytes payload, string symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress) external

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.

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

function payNativeGasForContractCall(address sender, string destinationChain, string destinationAddress, bytes payload, address refundAddress) external payable

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.

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

function payNativeGasForContractCallWithToken(address sender, string destinationChain, string destinationAddress, bytes payload, string symbol, uint256 amount, address refundAddress) external payable

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.

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

function payGasForExpressCall(address sender, string destinationChain, string destinationAddress, bytes payload, address gasToken, uint256 gasFeeAmount, address refundAddress) external

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.

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

function payGasForExpressCallWithToken(address sender, string destinationChain, string destinationAddress, bytes payload, string symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress) external

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.

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

function payNativeGasForExpressCall(address sender, string destinationChain, string destinationAddress, bytes payload, address refundAddress) external payable

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.

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

function payNativeGasForExpressCallWithToken(address sender, string destinationChain, string destinationAddress, bytes payload, string symbol, uint256 amount, address refundAddress) external payable

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.

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

function addGas(bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress) external

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.

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

function addNativeGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable

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.

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

function addExpressGas(bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress) external

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.

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

function addNativeExpressGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable

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.

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

function updateGasInfo(string[] chains, struct GasInfo[] gasUpdates) external

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.

Parameters

Name Type Description
chains string[] Array of chain names
gasUpdates struct GasInfo[] Array of gas updates

collectFees

function collectFees(address payable receiver, address[] tokens, uint256[] amounts) external

Allows the gasCollector to collect accumulated fees from the contract.

Use address(0) as the token address for native currency.

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

function refund(bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount) external

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.

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

gasCollector

function gasCollector() external returns (address)

Returns the address of the designated gas collector.

Return Values

Name Type Description
[0] address address of the gas collector