The Axelar CommandID
Ensuring the authenticity and integrity of messages is crucial in cross-chain communication. The CommandID
in the Axelar network plays a significant role in this process, acting as a unique identifier for interchain messages.
This guide explains what an Axelar CommandID
is, how it is generated, and its importance in the Solidity Axelar GMP SDK.
What is the Axelar CommandID
?
Axelar CommandID
is a unique identifier assigned to each message or command that facilitates interchain communication. It ensures that each message can be tracked, verified, and validated across different blockchain networks, preventing issues such as replay attacks or message tampering.
How is an Axelar CommandID
generated?
Generating an Axelar CommandID
involves combining specific attributes of the message, such as the sourceChain
, messageId
, and other relevant data, and then hashing this combination to produce a unique identifier. This process ensures that each CommandID
is unique for the message it represents.
Solidity Implementation
In the provided Solidity contract, the messageToCommandId()
function generates the CommandID
.
Here’s how it works:
This function takes two parameters: sourceChain
and messageId
. It concatenates these parameters with an underscore (_
) separator, ensuring the combination is unique and unambiguous. The concatenated string is then hashed using keccak256
to produce the CommandID
. You can view the source code here.
Go implementation
The CommandID
is generated similarly by hashing relevant data in the Go implementation.
Here’s an example function for generating a CommandID
:
This function combines the provided data and chain ID, then hashes the combination using Keccak256()
to produce the CommandID
. The source code for this can be found here.
Example commands
Here are a few examples of command creation in the provided Go code:
- Burn Token:
- Deploy Token:
Importance of the CommandID
for message verification
The CommandID
is key for verifying the authenticity and integrity of interchain messages. When a message is received on the destination chain, the CommandID
allows the system to:
- Verify Message Approval:
The
isMessageApproved()
function checks if a message has been approved by comparing the stored message hash with the calculated hash using theCommandID
. - Prevent Replay Attacks:
The
validateMessage()
function ensures that a message can only be executed once by marking it as executed after validation.
Refer to more detailed information on how Axelar verifies GMP transactions here.