AxelarGatewayAdapterLib
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
| Name | Type | Description |
|---|---|---|
| $ | AxelarGatewayAdapterStorage |
__AxelarGatewayAdapter_init
Configures the Axelar gateway and registers the IERC7786GatewaySource ERC-165 interface.
function __AxelarGatewayAdapter_init(address gateway_) internal;Parameters
| Name | Type | Description |
|---|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| <none> | address |
supportsAttribute
function supportsAttribute(bytes4) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| _ | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
getAxelarChain
function getAxelarChain(bytes memory chain) internal view returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| chain | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
getErc7930Chain
function getErc7930Chain(string memory axelar) internal view returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| axelar | string |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes |
getRemoteGateway
function getRemoteGateway(bytes memory chain) internal view returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| chain | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| chain | bytes | |
| axelar | string |
registerRemoteGateway
Registers a trusted remote gateway adapter (full ERC-7930 address). Admin only.
function registerRemoteGateway(bytes calldata remote) internal;Parameters
| Name | Type | Description |
|---|---|---|
| remote | bytes |
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
| Name | Type | Description |
|---|---|---|
| recipient | bytes | |
| payload | bytes | |
| attributes | bytes[] |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| commandId | bytes32 | |
| sourceChain | string | |
| sourceAddress | string | |
| adapterPayload | bytes |
_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
| Name | Type | Description |
|---|---|---|
| $ | AxelarGatewayAdapterStorage | |
| sourceChain | string | |
| sourceAddress | string |
_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
| Name | Type | Description |
|---|---|---|
| recipient | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| axelarDestination | string | |
| axelarTarget | string |
_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
| Name | Type | Description |
|---|---|---|
| chainType | bytes2 | |
| addr | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |