GlacisRouter
Your gateway to cross-chain activity.
The GlacisRouter smart contract acts as the on-chain interface for all cross-chain activity with Glacis.
You can discover the source smart contract GlacisRouter.sol
in this repository.
The Route Function
The main function in GlacisRouter is route, which sends a cross-chain message. It returns a bytes32
messageId and a uint256
nonce:
uint256 chainId
The Glacis ID of the blockchain that you wish to send a message to
address to
The address of the destination contract that you are sending a message to
bytes memory payload
The payload of data that you wish to send to the destination contract
address[] memory adapters
GlacisRouter.CrossChainGas[] memory fees
An array of fees that correspond to the amount provided to each adapter. This is a parallel array to the adapters parameter. The sum of the "nativeCurrencyValue" must be equal to the value sent with this function
address refundAddress
The address to which excess native currency is sent to if an adapter deems that the user overpaid
bool retriable
Whether to allow the message to be retried (stores owner of the message ID on-chain, slightly more gas expensive)
CrossChainGas
To represent how adapters require gas, we have created the CrossChainGas struct, located within the GlacisCommons contract.
uint128 gasLimit
A desired destination chain gas limit. Required by some adapters, and ignored by others
uint128 nativeCurrencyValue
The amount of source chain value to be forwarded to an adapter. Different GMPs require different fees
The Retry Route
There is an additional route function variant:
This route cannot be used for original cross-chain messages. Instead, it is used to retry a cross-chain message with an identical message ID and identical data (but potentially through a different GMP). For example, an original message was sent through Axelar but is now being retried via Wormhole.
This can be helpful in cases where a message is somehow lost by a GMP's consensus mechanism or its relayers. An identical message would be sent, and whichever message arrives after the first will revert.
Two additional parameters are required with this function:
bytes32 messageId
The Glacis message ID of the original message
uint256 nonce
The nonce of the message, which can be retrieved in the original message's event log
Only the original message sender can retry a message, no other address can do it on their behalf. The original message must have been sent with its "retryable" parameter as true. Identical data must be provided.
Read-Only
These are the read-only functions in GlacisRouter, but most developers won't use them:
glacisAdapters(uint8) returns(address)
Returns the address of the adapter contract for the specific GMP ID input
sourceAdapterToGMP(address) returns(uint8)
Returns the GMP ID of the adapter at the specified address. Returns 0 if no such adapter exists
validateGlacisMessageId(bytes32 messageId, uint256 toChainId, address to, uint256 nonce) returns(bool)
Returns true if the combination of chain ID, address, msg.sender, and message nonce result in the same messageId You can use the JSON-RPC method eth_call to simulate any msg.sender if you wish to use this in your application
messageSenders(bytes32)
Returns the message sender of a specific message ID
Errors
It also includes the following errors, some of which you may encounter:
GlacisRouter__GMPNotSupported
Occurs when routing, and the GMP ID provided is not supported on this chain
GlacisRouter__RouteDoesNotExist
Occurs when routing, and the adapter of the GMP ID does not exist
GlacisRouter__NotOwnerOfMessageToRetry
Occurs when retrying a message route, when the message ID that is attempting to be retried was not originally sent by the current message sender
GlacisRouter__OnlyAdaptersAllowed
Occurs when trying to call a function that only a Glacis GMP Adapter can call
GlacisRouter__MessageInputNotIdenticalForRetry
Occurs when retrying a message route, when the message input was not identical to the original
GlacisRouter__ClientDeniedRoute
Occurs when a message is received, and the client contract does not accept messages from the sender address, origin chain, and/or GMP
GlacisRouter__ImpossibleGMPId(uint8 gmpId)
Occurs when a message is received, and the GMP ID is not supported
GlacisRouter__MessageAlreadyReceivedFromGMP
Occurs when a message is received, and the same message has already been received from that GMP
GlacisRouter__MessageIdNotValid
Occurs when a message is received, and the Glacis message ID contained in the header does not pass verification
```
Last updated