axelar-gmp-sdk-solidity

Solidity API

AxelarExecutableWithToken

Abstract contract to be inherited by contracts that need to execute cross-chain commands involving tokens via Axelar’s Gateway. It extends AxelarExecutable and implements the IAxelarExecutableWithToken interface.

constructor

constructor(address gateway_) internal

Contract constructor that sets the Axelar Gateway With Token address and initializes AxelarExecutable.

Parameters

Name Type Description
gateway_ address The address of the Axelar Gateway With Token contract.

executeWithToken

function executeWithToken(bytes32 commandId, string sourceChain, string sourceAddress, bytes payload, string tokenSymbol, uint256 amount) external virtual

Executes the cross-chain command with token transfer after validating it with the Axelar Gateway.

This function ensures the call is approved by Axelar Gateway With Token before execution. It uses a hash of the payload for validation and calls _executeWithToken for the actual command execution. Reverts if the validation fails.

Parameters

Name Type Description
commandId bytes32 The unique identifier of the cross-chain message being executed.
sourceChain string The name of the source chain from which the message originated.
sourceAddress string The address on the source chain that sent the message.
payload bytes The payload of the message payload.
tokenSymbol string The symbol of the token to be transferred.
amount uint256 The amount of tokens to be transferred.

_executeWithToken

function _executeWithToken(bytes32 commandId, string sourceChain, string sourceAddress, bytes payload, string tokenSymbol, uint256 amount) internal virtual

Internal virtual function to be overridden by child contracts to execute the command with token transfer. It allows child contracts to define their custom command execution logic involving tokens.

Parameters

Name Type Description
commandId bytes32 The unique identifier of the cross-chain message being executed.
sourceChain string The name of the source chain from which the message originated.
sourceAddress string The address on the source chain that sent the message.
payload bytes The payload of the message payload.
tokenSymbol string The symbol of the token to be transferred.
amount uint256 The amount of tokens to be transferred.

gatewayWithToken

function gatewayWithToken() internal view returns (contract IAxelarGatewayWithToken)

Returns the address of the IAxelarGatewayWithToken contract.

Return Values

Name Type Description
[0] contract IAxelarGatewayWithToken The Axelar Gateway with Token instance.