An overview of the Inbox contract, responsible for managing intent fulfillment, preventing double fills, and solver whitelisting (for the Alpha).
Inbox
contract.Inbox
is responsible for fulfilling intents on the destination chain. It contains 6 primary functions:
fulfillStorage
— this function is used to fulfill requests that specified the Native Path (which uses storage proofs) during intent origination.
fulfillHyperInstant
— this function is used to fulfill requests that specified the Hyperprover Path during intent origination. It immediately dispatches a Hyperlane message to prove the intent fulfillment on the Origin chain.
fulfillHyperInstantWithRelayer
— this function is used to fulfill requests that specified the Hyperprover Path during intent origination. It immediately dispatches a Hyperlane message to prove the intent fulfillment on the Origin chain and allows for the use of any relayer for relaying the message.
fulfillHyperBatched
— this function is used to fulfill requests that specified the Hyperprover Path during intent origination. Instead of immediately dispatching, it allows intents to be queued in a batch message sent through Hyperlane later.
fulfillHyperBatchedWithRelayer
— this function is used to fulfill requests that specified the Hyperprover Path during intent origination. Instead of immediately dispatching, it allows intents to be queued in a batch message sent through Hyperlane later. It also allows for the use of any relayer for relaying the message.
sendBatch
— this function is used to send a batch of intents through Hyperlane that opted for the fulfillHyperBatched
option when filling an intent.
_fulfill
function on the Inbox
contract. All of the fulfilling methods enter this internal function, so it’s best to explain it first. The function accepts as input the route information, the reward hash, the claimant, and the expected hash. The reward hash is the hash of the reward struct that was used to fund the intent — using the hash allows for efficient use of calldata and gas.
The function first checks that the destination chain is correct, then checks that the solver is authorized to fulfill the intent, and then checks that the intent hash is valid. If the intent has already been fulfilled, the function reverts. If the intent is valid, the function then transfers the tokens to the inbox, calls the downstream functions requested by the intent, and then stores the results of the calls.
_fulfill
and then emits an event.
sendBatch
function takes a list of intent IDs, and relays them to a specific source chain via a batched Hyperlane message.
sendBatchWithRelayer
and fulfillHyperBatchedWithRelayer
. This is useful for users who want to use a specific relayer for their fulfillment. For information on how to run a relayer, please refer to the Relayer Documentation.
Inbox
contract, the hash is also used to prevent a given hash from being fulfilled more than once.
If a solver tries to solve an intent after another solver has successfully solved it, then the intent will revert with an IntentAlreadyFulfilled
error. This prevents solvers from accidentally solving intents twice.
This does create a race condition if two solvers submit transactions at the same time trying to solve the same intent. Future versions of the protocol will intend to deal with this for chains where conditional execution cannot be achieved through the use of bundlers (see Future Directions on the IntentSource
contract page).
Inbox
contract, which are also discussed in more detail in Future Directions.