Skip to content

Commit 8bd3ec0

Browse files
authored
feat: update gmp doc breaking 0.6 changes (#1238)
1 parent 62b5300 commit 8bd3ec0

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

public/samples/gmp-senderreceiver.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ contract SenderReceiver is AxelarExecutable {
2626
msg.sender
2727
);
2828

29-
gateway.callContract(destinationChain,destinationAddress,payload);
29+
gateway().callContract(destinationChain,destinationAddress,payload);
3030
}
3131

3232
function _execute(
33+
bytes32 commandId,
3334
string calldata sourceChain,
3435
string calldata sourceAddress,
3536
bytes calldata payload_

src/content/docs/dev/general-message-passing/executable.mdx

+40-10
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
## Overview
44

5-
The [Axelar Executable Contract](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/main/contracts/executable/AxelarExecutable.sol) is a component of the Axelar General Message Passing (GMP) flow, allowing the execution of custom logic in response to messages from different blockchains. By simply inheriting from the Axelar Executable your contract can process and respond to incoming cross-chain GMP data.
5+
The Axelar Executable is a component of the Axelar General Message Passing (GMP) flow, allowing the execution of custom logic in response to messages from different blockchains. By simply inheriting from the Axelar Executable your contract can process and respond to incoming cross-chain GMP data.
66

7-
## Integration
7+
## Integration For GMP Executable
8+
9+
For a [plain GMP executable](/dev/general-message-passing/gmp-tokens-with-messages/) message you can inherit from the [Axelar Executable](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/b5d0b7bdda0437fce983daffb776669437b809d0/contracts/executable/AxelarExecutable.sol) contract.
810

911
1. Import **`AxelarExecutable`** from the Axelar GMP SDK to enable cross-chain capabilities.
1012

@@ -18,40 +20,68 @@ The [Axelar Executable Contract](https://github.com/axelarnetwork/axelar-gmp-sdk
1820
contract MyContract is AxelarExecutable {}
1921
```
2022

21-
1. Implement the `virtual` functions defined in Axelar Executable on your own contracts. The functions you implement on your own contract will be automatically triggered by an Axelar relayer on the destination chain once the multichain transaction arrives on the destination chain
23+
1. Implement the `virtual` functions defined in `AxelarExecutable` on your own contracts. The functions you implement on your own contract will be automatically triggered by an Axelar relayer on the destination chain once the multichain transaction arrives on the destination chain
24+
25+
## Integration For GMP With Token Executable
26+
27+
If you are [sending a GMP message with a token](/dev/general-message-passing/gmp-tokens-with-messages/) and need to handle the executable for a token + gmp msg then you will need to inherit from the [Axelar Executable With Token](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/b5d0b7bdda0437fce983daffb776669437b809d0/contracts/executable/AxelarExecutableWithToken.sol) contract.
28+
29+
30+
1. Import **`AxelarExecutableWithToken`** from the Axelar GMP SDK to enable cross-chain capabilities.
31+
32+
```solidity
33+
import "@axelar-network/axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutableWithToken.sol";
34+
```
35+
36+
1. Inherit Axelar `AxelarExecutableWithToken` Functions:
37+
38+
```solidity
39+
contract MyContract is AxelarExecutableWithToken {}
40+
```
41+
42+
1. Implement the `virtual` functions defined in `AxelarExecutableWithToken` on your own contracts. The functions you implement on your own contract will be automatically triggered by an Axelar relayer on the destination chain once the multichain transaction arrives on the destination chain
43+
44+
2245

23-
## GMP Message vs. GMP Message With Token
46+
## Implementation Comparison
2447

25-
There are two relevant functions that can be overriden from AxelarExecutable. The function you want to override depends on whether your sending a GMP message or a GMP message WITH a [Gateway Token](/resources/contract-addresses/mainnet#assets). These two functions are [\_execute()](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/be86ab9a171f8e12d7695127cf1a6ca867fa1b09/contracts/executable/AxelarExecutable.sol#L55) and [\_executeWithToken()](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/be86ab9a171f8e12d7695127cf1a6ca867fa1b09/contracts/executable/AxelarExecutable.sol#L61)
48+
Once you have inherited from the respective Executable contract you can now defined the execution function. This varies slightly depending on whether you are using an execution for a plain GMP message or a GMP message with a token.
2649

50+
<tabs>
51+
<tab-item title="execute">
2752
```solidity
2853
/*** For GMP Message ***/
2954
/**
55+
@param commandId identifier tx that is guaranteed to be unique from the Axelar network
3056
@param sourceChain The chain where the GMP message is sent from
3157
@param sourceAddress The address on where the GMP msg is sent from
3258
@param payload The GMP message being sent
3359
**/
34-
function _execute(string calldata sourceChain, string calldata sourceAddress, bytes calldata payload) internal override {
60+
function _execute(bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload) internal override {
3561
// Implement your logic on the destination chain
3662
string memory myGmpMessage = abi.decode(payload, (string));
37-
3863
}
39-
64+
```
65+
</tab-item>
66+
<tab-item title="executeWithToken">
67+
```solidity
4068
/*** For GMP Message + Token ***/
4169
/**
70+
@param commandId identifier tx that is guaranteed to be unique from the Axelar network
4271
@param sourceChain The chain where the GMP message is sent from
4372
@param sourceAddress The address on where the GMP msg is sent from
4473
@param payload The GMP message being sent
4574
@param tokenSymbol The token being sent
4675
@param amount The amount of the token being sent
4776
**/
48-
function _executeWithToken(string calldata sourceChain, string calldata sourceAddress, bytes calldata payload, string calldata tokenSymbol, uint256 amount) internal override {
77+
function _executeWithToken(bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload, string calldata tokenSymbol, uint256 amount) internal override {
4978
address memory receiver = abi.decode(payload, (address));
5079
address tokenAddress = gateway.tokenAddresses(tokenSymbol);
5180
IERC20(tokenAddress).transfer(receiver, amount);
5281
}
53-
5482
```
83+
</tab-item>
84+
</tabs>
5585

5686
## Incoming Message Validation
5787

src/content/docs/dev/general-message-passing/gmp-messages.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import { Callout } from "/src/components/callout";
77
className="aspect-video"
88
src="https://www.youtube.com/embed/htMVIYzGA34"
99
title="YouTube video player"
10-
frameBorder="0"
1110
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
1211
allowFullScreen
1312
></iframe>
1413

1514
To call a contract on chain B from chain A, the user needs to call `callContract` on the gateway of chain A, specifying:
1615

17-
- The destination chain, which must be an EVM chain from [Chain names](/dev/reference/mainnet-chain-names).
16+
- The destination chain, which must be an EVM chain from [Chain names](/dev/reference/mainnet-chain-names/).
1817
- The destination contract address, which must inherit from `AxelarExecutable` defined in [AxelarExecutable.sol](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/main/contracts/executable/AxelarExecutable.sol).
1918
- The payload `bytes` to pass to the destination contract.
2019

@@ -39,6 +38,7 @@ function callContract(
3938

4039
```solidity
4140
function _execute(
41+
bytes32 commandId,
4242
string memory sourceChain,
4343
string memory sourceAddress,
4444
bytes calldata payload
@@ -65,6 +65,7 @@ Example of payload decoding in Solidity:
6565

6666
```solidity
6767
function _execute(
68+
bytes32 commandId,
6869
string memory sourceChain,
6970
string memory sourceAddress,
7071
bytes calldata payload

src/content/docs/dev/general-message-passing/gmp-tokens-with-messages.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Callout } from "/src/components/callout";
1414
To call chain B from chain A and send some tokens along the way, the user needs to call `callContractWithToken` on the gateway of chain A, specifying:
1515

1616
- The destination chain, which must be an EVM chain from [Chain names](/dev/reference/mainnet-chain-names/).
17-
- The destination contract address, which must inherit from `AxelarExecutable` defined in [AxelarExecutable.sol](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/main/contracts/executables/AxelarExecutable.sol).
17+
- The destination contract address, which must inherit from `AxelarExecutable` defined in [AxelarExecutable.sol](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/main/contracts/executable/AxelarExecutable.sol).
1818
- The payload `bytes` to pass to the destination contract.
1919
- The symbol of the token to transfer, which must be a supported asset ([Mainnet](/resources/contract-addresses/mainnet/) | [Testnet](/resources/contract-addresses/testnet/)).
2020
- The amount of the token to transfer.

0 commit comments

Comments
 (0)