Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MockAxelarGateway

Git Source

Inherits: IAxelarGatewayWithToken

Title: AxelarGateway Contract

This contract serves as the gateway for cross-chain contract calls, and token transfers within the Axelar network. It includes functions for sending tokens, calling contracts, and validating contract calls. The contract is managed via the decentralized governance mechanism on the Axelar network.

EternalStorage is used to simplify storage for upgradability, and InterchainGovernance module is used for governance.

State Variables

tokenMapping

mapping(string => address) tokenMapping

Functions

constructor

constructor() ;

sendToken

Sends tokens to another chain.

Initiates a cross-chain token transfer through the gateway to the specified destination chain and recipient.

function sendToken(
    string calldata destinationChain,
    string calldata destinationAddress,
    string calldata symbol,
    uint256 amount
) external;

Parameters

NameTypeDescription
destinationChainstringThe name of the destination chain.
destinationAddressstringThe address of the recipient on the destination chain.
symbolstringThe symbol of the token being transferred.
amountuint256The amount of the tokens being transferred.

callContractWithToken

Makes a contract call on another chain with an associated token transfer.

Initiates a cross-chain contract call through the gateway that includes a token transfer to the specified contract on the destination chain.

function callContractWithToken(
    string calldata destinationChain,
    string calldata contractAddress,
    bytes calldata payload,
    string calldata symbol,
    uint256 amount
) external;

Parameters

NameTypeDescription
destinationChainstringThe name of the destination chain.
contractAddressstringThe address of the contract on the destination chain.
payloadbytesThe payload data to be used in the contract call.
symbolstringThe symbol of the token being transferred.
amountuint256The amount of the tokens being transferred.

isContractCallAndMintApproved

Checks if a contract call with token minting is approved.

Determines whether a given contract call, identified by the commandId and payloadHash, involving token minting is approved.

function isContractCallAndMintApproved(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    address contractAddress,
    bytes32 payloadHash,
    string calldata symbol,
    uint256 amount
) external view returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to check.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
contractAddressaddressThe address of the contract where the call will be executed.
payloadHashbytes32The keccak256 hash of the payload data.
symbolstringThe symbol of the token associated with the minting.
amountuint256The amount of the tokens to be minted.

Returns

NameTypeDescription
<none>boolTrue if the contract call with token minting is approved, false otherwise.

validateContractCallAndMint

Validates and approves a contract call with token minting.

Validates the given contract call information and marks it as approved if valid. It also involves the minting of tokens.

function validateContractCallAndMint(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    bytes32 payloadHash,
    string calldata symbol,
    uint256 amount
) external returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to validate.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
payloadHashbytes32The keccak256 hash of the payload data.
symbolstringThe symbol of the token associated with the minting.
amountuint256The amount of the tokens to be minted.

Returns

NameTypeDescription
<none>boolTrue if the contract call with token minting is validated and approved, false otherwise.

tokenAddresses

Retrieves the address of a token given its symbol.

Gets the contract address of the token registered with the given symbol.

function tokenAddresses(string memory symbol) external view returns (address);

Parameters

NameTypeDescription
symbolstringThe symbol of the token to retrieve the address for.

Returns

NameTypeDescription
<none>addressThe contract address of the token corresponding to the given symbol.

setTokenAddress

Sets the address of a token given its symbol.

Sets the contract address of the token registered with the given symbol.

function setTokenAddress(string memory symbol, address tokenAddress) external;

Parameters

NameTypeDescription
symbolstringThe symbol of the token.
tokenAddressaddressThe address of the token.

callContract

Sends a contract call to another chain.

Initiates a cross-chain contract call through the gateway to the specified destination chain and contract.

function callContract(string calldata destinationChain, string calldata contractAddress, bytes calldata payload)
    external;

Parameters

NameTypeDescription
destinationChainstringThe name of the destination chain.
contractAddressstringThe address of the contract on the destination chain.
payloadbytesThe payload data to be used in the contract call.

isContractCallApproved

Checks if a contract call is approved.

Determines whether a given contract call, identified by the commandId and payloadHash, is approved.

function isContractCallApproved(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    address contractAddress,
    bytes32 payloadHash
) external view returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to check.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
contractAddressaddressThe address of the contract where the call will be executed.
payloadHashbytes32The keccak256 hash of the payload data.

Returns

NameTypeDescription
<none>boolTrue if the contract call is approved, false otherwise.

validateContractCall

Validates and approves a contract call.

Validates the given contract call information and marks it as approved if valid.

function validateContractCall(
    bytes32 commandId,
    string calldata sourceChain,
    string calldata sourceAddress,
    bytes32 payloadHash
) external returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to validate.
sourceChainstringThe name of the source chain.
sourceAddressstringThe address of the sender on the source chain.
payloadHashbytes32The keccak256 hash of the payload data.

Returns

NameTypeDescription
<none>boolTrue if the contract call is validated and approved, false otherwise.

isCommandExecuted

Checks if a command has been executed.

Determines whether a command, identified by the commandId, has been executed.

function isCommandExecuted(bytes32 commandId) external view returns (bool);

Parameters

NameTypeDescription
commandIdbytes32The identifier of the command to check.

Returns

NameTypeDescription
<none>boolTrue if the command has been executed, false otherwise.