Skip to main content

Overview

IntentSource is an abstract contract containing all core intent functionality for EVM chains. It manages the lifecycle of cross-chain intents and their associated rewards on the source chain. Contract Location: contracts/IntentSource.sol Inherits: OriginSettler, IIntentSource

State Variables

Status Enum

Tracks the lifecycle status of each intent’s rewards.

View Functions

getRewardStatus

Retrieves reward status for a given intent hash.
bytes32
Hash of the intent to query
Status
Current status of the intent (Initial, Funded, Withdrawn, or Refunded)

getIntentHash (Intent)

Calculates the hash of an intent and its components.
Intent
The intent to hash
bytes32
Combined hash of route and reward
bytes32
Hash of the route component
bytes32
Hash of the reward component

getIntentHash (Destination, Route, Reward)

Calculates the hash of an intent and its components using encoded route data.
uint64
Destination chain ID for the intent
bytes
Encoded route data for the intent as bytes for cross-VM compatibility
Reward
Reward structure containing distribution details
bytes32
Combined hash of route and reward
bytes32
Hash of the route component
bytes32
Hash of the reward component

getIntentHash (Route Hash)

Calculates intent hash from pre-computed route hash and reward components.
uint64
Destination chain ID for the intent
bytes32
Pre-computed hash of the route component
Reward
Reward structure containing distribution details
bytes32
Combined hash of route and reward
bytes32
Hash of the route component (passed through)
bytes32
Hash of the reward component

intentVaultAddress (Intent)

Calculates the deterministic address of the intent vault.
Intent
Intent to calculate vault address for
address
Address of the intent vault

intentVaultAddress (Destination, Route, Reward)

Calculates the deterministic address of the intent vault using universal format.
uint64
Destination chain ID for the intent
bytes
Encoded route data for the intent as bytes
Reward
The reward structure containing distribution details
address
Address of the intent vault

isIntentFunded (Intent)

Checks if an intent is completely funded.
Intent
Intent to validate
bool
True if intent is completely funded, false otherwise

isIntentFunded (Destination, Route, Reward)

Checks if an intent is fully funded using universal format.
uint64
Destination chain ID for the intent
bytes
Encoded route data for the intent as bytes
Reward
The reward structure containing distribution details
bool
True if intent is completely funded, false otherwise

State-Changing Functions

publish (Intent)

Creates an intent without funding.
Intent
The complete intent struct to be published
bytes32
Hash of the created intent
address
Address of the created vault

publish (Destination, Route, Reward)

Creates an intent without funding using universal format.
uint64
Destination chain ID for the intent
bytes
Encoded route data for the intent as bytes
Reward
The reward structure containing distribution details
bytes32
Hash of the created intent
address
Address of the created vault

publishAndFund (Intent)

Creates and funds an intent in a single transaction.
Intent
The complete intent struct to be published and funded
bool
Whether to allow partial funding
bytes32
Hash of the created and funded intent
address
Address of the created vault
This function is payable to accept native token (ETH) for funding.

publishAndFund (Destination, Route, Reward)

Creates and funds an intent in a single transaction using universal format.
uint64
Destination chain ID for the intent
bytes
Encoded route data for the intent as bytes
Reward
The reward structure containing distribution details
bool
Whether to allow partial funding
bytes32
Hash of the created and funded intent
address
Address of the created vault

fund

Funds an existing intent.
uint64
Destination chain ID for the intent
bytes32
Hash of the route component
Reward
Reward structure containing distribution details
bool
Whether to allow partial funding
bytes32
Hash of the funded intent
Prevents funding of intents that are already withdrawn or refunded. Allows funding of Initial or Funded status intents for partial funding.

fundFor

Funds an intent for a user with permit/allowance.
uint64
Destination chain ID for the intent
bytes32
Hash of the route component
Reward
Reward structure containing distribution details
bool
Whether to allow partial funding
address
Address to fund the intent from
address
Address of the permitContract instance
bytes32
Hash of the funded intent

publishAndFundFor (Intent)

Creates and funds an intent using permit/allowance.
Intent
The complete intent struct
bool
Whether to allow partial funding
address
Address to fund the intent from
address
Address of the permitContract instance
bytes32
Hash of the created and funded intent
address
Address of the created vault

publishAndFundFor (Destination, Route, Reward)

Creates and funds an intent on behalf of another address using universal format.
uint64
Destination chain ID for the intent
bytes
Encoded route data for the intent as bytes
Reward
The reward structure containing distribution details
bool
Whether to accept partial funding
address
The address providing the funding
address
The permit contract for token approvals
bytes32
Hash of the created and funded intent
address
Address of the created vault

withdraw

Withdraws rewards associated with an intent to its claimant.
uint64
Destination chain ID for the intent
bytes32
Hash of the intent’s route
Reward
Reward structure of the intent
If the intent has been proven on a different chain, this function will challenge the proof instead of withdrawing.

batchWithdraw

Batch withdraws multiple intents.
uint64[]
Array of destination chain IDs for the intents
bytes32[]
Array of route hashes for the intents
Reward[]
Array of reward structures for the intents
All arrays must have the same length, or the function will revert with ArrayLengthMismatch.

refund

Refunds rewards to the intent creator.
uint64
Destination chain ID for the intent
bytes32
Hash of the intent’s route
Reward
Reward structure of the intent
Can only be called after the reward deadline has passed, and only if the intent has not been proven/claimed.

refundTo

Refunds rewards to a specified address (only callable by reward creator).
uint64
Destination chain ID for the intent
bytes32
Hash of the intent’s route
Reward
Reward structure of the intent
address
Address to receive the refunded rewards
Only the reward creator (reward.creator) can call this function.

recoverToken

Recover tokens that were sent to the intent vault by mistake.
uint64
Destination chain ID for the intent
bytes32
Hash of the intent’s route
Reward
Reward structure of the intent
address
Token address for handling incorrect vault transfers
The token must not be among the intent’s reward tokens. This function is for recovering tokens sent to the vault by mistake.

Events

IntentPublished

Emitted when a new intent is published.

IntentFunded

Emitted when an intent is funded (fully or partially).

IntentWithdrawn

Emitted when rewards are withdrawn to a claimant.

IntentRefunded

Emitted when rewards are refunded.

IntentTokenRecovered

Emitted when tokens are recovered from a vault.