Overview
Send and receive GMP messages from Solidity contracts on EVM chains.
On EVM chains, a contract sends a message by calling callContract on Axelar's gateway contract, and receives one by implementing _execute from AxelarExecutable. The contracts are in axelar-gmp-sdk-solidity.
EVM contracts can exchange messages with every connected chain, not only other EVM chains. To send tokens, use the Interchain Token Service.
Using an AI agent?
Copy this page with Copy Markdown at the top and give it to your agent, with what you want to build or the contract you want to make cross-chain. The copied page links to the Markdown of the other pages it refers to, so the agent can read them too. Review what it writes, and test on testnet before mainnet.
Message flow
Sending, on the source chain:
- Your contract pays gas to the gas service (
payNativeGasForContractCall). - Your contract calls
callContracton the gateway, which emits aContractCallevent.
Receiving, on the destination chain:
- Axelar verifies the event and approves the message on the gateway.
- A relayer calls
executeon your contract. AxelarExecutableasks the gateway to validate the message, which marks it executed, then calls your_execute.
Consensus and Amplifier chains
EVM chains connect to Axelar in one of two ways (see Amplifier), with a different gateway contract. Contracts that send and receive plain messages work the same way on both: AxelarExecutable supports both gateways.
| Consensus chains | Amplifier chains | |
|---|---|---|
| Gateway contract | AxelarGateway | AxelarAmplifierGateway |
callContract | Yes | Yes |
callContractWithToken | Yes | No |
| Command ID | Assigned by Axelar | keccak256(sourceChain + "_" + messageId) |
| Approval event | ContractCallApproved | MessageApproved |
Chains and contracts shows each chain's type. The contract reference has the details.
Setup
Install the SDK:
# npm
npm install @axelar-network/axelar-gmp-sdk-solidity
# Foundry
forge install axelarnetwork/axelar-gmp-sdk-solidityWith Foundry, add a remapping so the imports in these docs resolve:
@axelar-network/axelar-gmp-sdk-solidity/=lib/axelar-gmp-sdk-solidity/Your contract needs two addresses on each chain it's deployed to, the gateway and the gas service. Both are on Chains and contracts.
Chain names
Contracts identify chains by their Axelar name, such as arbitrum or base, not by EVM chain ID. Names are listed on Axelarscan: mainnet | testnet.
When sending, chain names are case-insensitive. When receiving, sourceChain is the name exactly as the chain was registered, and some older chains were registered capitalized: Ethereum, Avalanche, Polygon, Fantom and Moonbeam. Compare it to the exact string. The source chain of a message is shown on its Axelarscan page.
Next steps
- Send and receive messages: a complete contract, and the checks your contract must make.
- Messages with tokens: send a message with gateway tokens, between consensus chains.
- Express: execute messages before the source chain is final.
- Contract reference: gateway functions and events.
- Deployers and libraries: deploy to the same address on every chain, and helper libraries.
Resources
- axelar-gmp-sdk-solidity: executables, the Amplifier gateway, deployers and libraries.
- axelar-cgp-solidity: the gateway and gas service on consensus chains.
- axelar-examples: example apps.
- axelar-local-dev: run cross-chain tests against local chains.