Skip to content
Lattice

AxelarGatewayAdapterLib

Git Source

Title: AxelarGatewayAdapterLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Adapted for EIP-2535 from OpenZeppelin community-contracts AxelarGatewayAdapter (https://github.com/OpenZeppelin/openzeppelin-community-contracts, commit f7e5f08).

Dual-mode ERC-7786 gateway over Axelar GMP: sendMessage (source) calls the Axelar gateway's callContract; execute (destination) validates an approved call + the trusted source gateway, then delivers to the ERC-7786 recipient. EVM chains only. Gas is handled off-band (no gas service).

Functions

axelarGatewayAdapterStorage

function axelarGatewayAdapterStorage() internal pure returns (AxelarGatewayAdapterStorage storage $);

Returns

NameTypeDescription
$AxelarGatewayAdapterStorage

__AxelarGatewayAdapter_init

Configures the Axelar gateway and registers the IERC7786GatewaySource ERC-165 interface.

function __AxelarGatewayAdapter_init(address gateway_) internal;

Parameters

NameTypeDescription
gateway_address

registerInterface

Writes true to the ERC-165 map slot for IERC7786GatewaySource (shared by gateway adapters).

function registerInterface() internal;

gateway

function gateway() internal view returns (address);

Returns

NameTypeDescription
<none>address

supportsAttribute

function supportsAttribute(bytes4) internal pure returns (bool);

Parameters

NameTypeDescription
_bytes4

Returns

NameTypeDescription
<none>bool

getAxelarChain

function getAxelarChain(bytes memory chain) internal view returns (string memory);

Parameters

NameTypeDescription
chainbytes

Returns

NameTypeDescription
<none>string

getErc7930Chain

function getErc7930Chain(string memory axelar) internal view returns (bytes memory);

Parameters

NameTypeDescription
axelarstring

Returns

NameTypeDescription
<none>bytes

getRemoteGateway

function getRemoteGateway(bytes memory chain) internal view returns (bytes memory);

Parameters

NameTypeDescription
chainbytes

Returns

NameTypeDescription
<none>bytes

registerChainEquivalence

Registers a CAIP-2 ↔ Axelar chain-name equivalence (both directions). Admin only.

function registerChainEquivalence(bytes calldata chain, string calldata axelar) internal;

Parameters

NameTypeDescription
chainbytes
axelarstring

registerRemoteGateway

Registers a trusted remote gateway adapter (full ERC-7930 address). Admin only.

function registerRemoteGateway(bytes calldata remote) internal;

Parameters

NameTypeDescription
remotebytes

sendMessage

ERC-7786 source: emits the message to the trusted remote gateway via Axelar callContract.

Fire-and-forget — returns bytes32(0). Rejects native value and any attribute. Gas is off-band.

function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)
        internal
        returns (bytes32);

Parameters

NameTypeDescription
recipientbytes
payloadbytes
attributesbytes[]

Returns

NameTypeDescription
<none>bytes32

execute

Axelar destination: validate the approved call + the trusted source gateway, then deliver.

function execute(
        bytes32 commandId,
        string calldata sourceChain,
        string calldata sourceAddress,
        bytes calldata adapterPayload
    ) internal;

Parameters

NameTypeDescription
commandIdbytes32
sourceChainstring
sourceAddressstring
adapterPayloadbytes

_checkOriginGateway

Reverts unless sourceAddress equals the registered remote gateway for sourceChain (checksummed-string compare, Axelar's address form).

function _checkOriginGateway(
        AxelarGatewayAdapterStorage storage $,
        string calldata sourceChain,
        string calldata sourceAddress
    ) private view;

Parameters

NameTypeDescription
$AxelarGatewayAdapterStorage
sourceChainstring
sourceAddressstring

_resolveDestination

Resolves a recipient's chain into the Axelar destination chain name + the trusted remote gateway's Axelar address string. Split out to keep sendMessage below the stack limit.

function _resolveDestination(bytes calldata recipient)
        private
        view
        returns (string memory axelarDestination, string memory axelarTarget);

Parameters

NameTypeDescription
recipientbytes

Returns

NameTypeDescription
axelarDestinationstring
axelarTargetstring

_stringifyAddress

Stringifies an interoperable address part for Axelar (EVM only → EIP-55 checksummed hex).

function _stringifyAddress(bytes2 chainType, bytes memory addr) internal pure returns (string memory);

Parameters

NameTypeDescription
chainTypebytes2
addrbytes

Returns

NameTypeDescription
<none>string