bytes32 BASE_AMPLIFIER_GATEWAY_SLOT
This slot contains the storage for this contract in an upgrade-compatible manner keccak256(‘BaseAmplifierGateway.Slot’) - 1;
bytes32 MESSAGE_NONEXISTENT
Message can be in one of three states: non-existent, approved, or executed Non-existent: The message has not been seen before. Equal to 0 Approved: The message has been seen and approved. Equal to keccak256 of the message data Executed: The message has been seen and executed. Equal to 1
bytes32 MESSAGE_EXECUTED
Storage for this contract
| Name | Type | Description | | —- | —- | ———– |
struct BaseAmplifierGatewayStorage {
mapping(bytes32 => bytes32) messages;
}
function callContract(string destinationChain, string destinationContractAddress, bytes payload) external
Sends a message to the specified destination chain and address with a given payload. This function is the entry point for general message passing between chains.
Name | Type | Description |
---|---|---|
destinationChain | string | The chain where the destination contract exists. A registered chain name on Axelar must be used here |
destinationContractAddress | string | The address of the contract to call on the destination chain |
payload | bytes | The payload to be sent to the destination contract |
function isMessageApproved(string sourceChain, string messageId, string sourceAddress, address contractAddress, bytes32 payloadHash) external view returns (bool)
Checks if a message is approved.
Determines whether a given message, identified by the sourceChain and messageId, is approved.
Name | Type | Description |
---|---|---|
sourceChain | string | The name of the source chain. |
messageId | string | The unique identifier of the message. |
sourceAddress | string | The address of the sender on the source chain. |
contractAddress | address | The address of the contract where the call will be executed. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the contract call is approved, false otherwise. |
function isMessageExecuted(string sourceChain, string messageId) external view returns (bool)
Checks if a message is executed.
Determines whether a given message, identified by the sourceChain and messageId is executed.
Name | Type | Description |
---|---|---|
sourceChain | string | The name of the source chain. |
messageId | string | The unique identifier of the message. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the message is executed, false otherwise. |
function validateMessage(string sourceChain, string messageId, string sourceAddress, bytes32 payloadHash) external returns (bool valid)
Validates if a message is approved. If message was in approved status, status is updated to executed to avoid replay.
Name | Type | Description |
---|---|---|
sourceChain | string | The name of the source chain. |
messageId | string | The unique identifier of the message. |
sourceAddress | string | The address of the sender on the source chain. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
Name | Type | Description |
---|---|---|
valid | bool | True if the message is approved, false otherwise. |
function messageToCommandId(string sourceChain, string messageId) public pure returns (bytes32)
Compute the commandId for a message.
Name | Type | Description |
---|---|---|
sourceChain | string | The name of the source chain as registered on Axelar. |
messageId | string | The unique message id for the message. |
Name | Type | Description |
---|---|---|
[0] | bytes32 | The commandId for the message. |
function isCommandExecuted(bytes32 commandId) public view returns (bool)
The below methods are available for backwards compatibility with the original AxelarExecutable Other implementations can skip these methods.
function isContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) external view returns (bool)
Checks if a contract call is approved.
Determines whether a given contract call, identified by the commandId and payloadHash, is approved.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to check. |
sourceChain | string | The name of the source chain. |
sourceAddress | string | The address of the sender on the source chain. |
contractAddress | address | The address of the contract where the call will be executed. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the contract call is approved, false otherwise. |
function validateContractCall(bytes32 commandId, string sourceChain, string sourceAddress, bytes32 payloadHash) external returns (bool valid)
Validates and approves a contract call.
Validates the given contract call information and marks it as approved if valid.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to validate. |
sourceChain | string | The name of the source chain. |
sourceAddress | string | The address of the sender on the source chain. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
Name | Type | Description |
---|---|---|
valid | bool | True if the contract call is validated and approved, false otherwise. |
function _approveMessages(struct Message[] messages) internal
Approves an array of messages.
Name | Type | Description |
---|---|---|
messages | struct Message[] | The array of messages to verify. |
function _isMessageApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) internal view returns (bool)
function _validateMessage(bytes32 commandId, string sourceChain, string sourceAddress, bytes32 payloadHash) internal returns (bool valid)
For backwards compatibility with validateContractCall
, commandId
is used here instead of messageId
.
Name | Type | Description |
---|---|---|
valid | bool | True if message is valid |
function _approveMessage(struct Message message) internal
Approves a message if it hasn’t been approved before. The message status is set to approved.
function _messageHash(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) internal pure returns (bytes32)
For backwards compatibility with validateContractCall
, commandId
is used here instead of messageId
.
Name | Type | Description |
---|---|---|
[0] | bytes32 | bytes32 the message hash |