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

enum Status {
    Initial,
    Funded,
    Withdrawn,
    Refunded
}
Tracks the lifecycle status of each intent’s rewards.

View Functions

getRewardStatus

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

getIntentHash (Intent)

function getIntentHash(
    Intent memory intent
) public pure returns (
    bytes32 intentHash,
    bytes32 routeHash,
    bytes32 rewardHash
)
Calculates the hash of an intent and its components.
intent
Intent
The intent to hash
intentHash
bytes32
Combined hash of route and reward
routeHash
bytes32
Hash of the route component
rewardHash
bytes32
Hash of the reward component

getIntentHash (Destination, Route, Reward)

function getIntentHash(
    uint64 destination,
    bytes memory route,
    Reward memory reward
) public pure returns (
    bytes32 intentHash,
    bytes32 routeHash,
    bytes32 rewardHash
)
Calculates the hash of an intent and its components using encoded route data.
destination
uint64
Destination chain ID for the intent
route
bytes
Encoded route data for the intent as bytes for cross-VM compatibility
reward
Reward
Reward structure containing distribution details
intentHash
bytes32
Combined hash of route and reward
routeHash
bytes32
Hash of the route component
rewardHash
bytes32
Hash of the reward component

getIntentHash (Route Hash)

function getIntentHash(
    uint64 destination,
    bytes32 _routeHash,
    Reward memory reward
) public pure returns (
    bytes32 intentHash,
    bytes32 routeHash,
    bytes32 rewardHash
)
Calculates intent hash from pre-computed route hash and reward components.
destination
uint64
Destination chain ID for the intent
_routeHash
bytes32
Pre-computed hash of the route component
reward
Reward
Reward structure containing distribution details
intentHash
bytes32
Combined hash of route and reward
routeHash
bytes32
Hash of the route component (passed through)
rewardHash
bytes32
Hash of the reward component

intentVaultAddress (Intent)

function intentVaultAddress(Intent calldata intent) public view returns (address)
Calculates the deterministic address of the intent vault.
intent
Intent
Intent to calculate vault address for
address
address
Address of the intent vault

intentVaultAddress (Destination, Route, Reward)

function intentVaultAddress(
    uint64 destination,
    bytes memory route,
    Reward calldata reward
) public view returns (address)
Calculates the deterministic address of the intent vault using universal format.
destination
uint64
Destination chain ID for the intent
route
bytes
Encoded route data for the intent as bytes
reward
Reward
The reward structure containing distribution details
address
address
Address of the intent vault

isIntentFunded (Intent)

function isIntentFunded(Intent calldata intent) public view returns (bool)
Checks if an intent is completely funded.
intent
Intent
Intent to validate
bool
bool
True if intent is completely funded, false otherwise

isIntentFunded (Destination, Route, Reward)

function isIntentFunded(
    uint64 destination,
    bytes memory route,
    Reward calldata reward
) public view returns (bool)
Checks if an intent is fully funded using universal format.
destination
uint64
Destination chain ID for the intent
route
bytes
Encoded route data for the intent as bytes
reward
Reward
The reward structure containing distribution details
bool
bool
True if intent is completely funded, false otherwise

State-Changing Functions

publish (Intent)

function publish(
    Intent calldata intent
) public returns (
    bytes32 intentHash,
    address vault
)
Creates an intent without funding.
intent
Intent
The complete intent struct to be published
intentHash
bytes32
Hash of the created intent
vault
address
Address of the created vault

publish (Destination, Route, Reward)

function publish(
    uint64 destination,
    bytes memory route,
    Reward memory reward
) public returns (
    bytes32 intentHash,
    address vault
)
Creates an intent without funding using universal format.
destination
uint64
Destination chain ID for the intent
route
bytes
Encoded route data for the intent as bytes
reward
Reward
The reward structure containing distribution details
intentHash
bytes32
Hash of the created intent
vault
address
Address of the created vault

publishAndFund (Intent)

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

publishAndFund (Destination, Route, Reward)

function publishAndFund(
    uint64 destination,
    bytes memory route,
    Reward calldata reward,
    bool allowPartial
) public payable returns (
    bytes32 intentHash,
    address vault
)
Creates and funds an intent in a single transaction using universal format.
destination
uint64
Destination chain ID for the intent
route
bytes
Encoded route data for the intent as bytes
reward
Reward
The reward structure containing distribution details
allowPartial
bool
Whether to allow partial funding
intentHash
bytes32
Hash of the created and funded intent
vault
address
Address of the created vault

fund

function fund(
    uint64 destination,
    bytes32 routeHash,
    Reward calldata reward,
    bool allowPartial
) external payable returns (bytes32 intentHash)
Funds an existing intent.
destination
uint64
Destination chain ID for the intent
routeHash
bytes32
Hash of the route component
reward
Reward
Reward structure containing distribution details
allowPartial
bool
Whether to allow partial funding
intentHash
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

function fundFor(
    uint64 destination,
    bytes32 routeHash,
    Reward calldata reward,
    bool allowPartial,
    address funder,
    address permitContract
) external payable returns (bytes32 intentHash)
Funds an intent for a user with permit/allowance.
destination
uint64
Destination chain ID for the intent
routeHash
bytes32
Hash of the route component
reward
Reward
Reward structure containing distribution details
allowPartial
bool
Whether to allow partial funding
funder
address
Address to fund the intent from
permitContract
address
Address of the permitContract instance
intentHash
bytes32
Hash of the funded intent

publishAndFundFor (Intent)

function publishAndFundFor(
    Intent calldata intent,
    bool allowPartial,
    address funder,
    address permitContract
) public payable returns (
    bytes32 intentHash,
    address vault
)
Creates and funds an intent using permit/allowance.
intent
Intent
The complete intent struct
allowPartial
bool
Whether to allow partial funding
funder
address
Address to fund the intent from
permitContract
address
Address of the permitContract instance
intentHash
bytes32
Hash of the created and funded intent
vault
address
Address of the created vault

publishAndFundFor (Destination, Route, Reward)

function publishAndFundFor(
    uint64 destination,
    bytes memory route,
    Reward calldata reward,
    bool allowPartial,
    address funder,
    address permitContract
) public payable returns (
    bytes32 intentHash,
    address vault
)
Creates and funds an intent on behalf of another address using universal format.
destination
uint64
Destination chain ID for the intent
route
bytes
Encoded route data for the intent as bytes
reward
Reward
The reward structure containing distribution details
allowPartial
bool
Whether to accept partial funding
funder
address
The address providing the funding
permitContract
address
The permit contract for token approvals
intentHash
bytes32
Hash of the created and funded intent
vault
address
Address of the created vault

withdraw

function withdraw(
    uint64 destination,
    bytes32 routeHash,
    Reward calldata reward
) public
Withdraws rewards associated with an intent to its claimant.
destination
uint64
Destination chain ID for the intent
routeHash
bytes32
Hash of the intent’s route
reward
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

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

refund

function refund(
    uint64 destination,
    bytes32 routeHash,
    Reward calldata reward
) external
Refunds rewards to the intent creator.
destination
uint64
Destination chain ID for the intent
routeHash
bytes32
Hash of the intent’s route
reward
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

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

recoverToken

function recoverToken(
    uint64 destination,
    bytes32 routeHash,
    Reward calldata reward,
    address token
) external
Recover tokens that were sent to the intent vault by mistake.
destination
uint64
Destination chain ID for the intent
routeHash
bytes32
Hash of the intent’s route
reward
Reward
Reward structure of the intent
token
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

event IntentPublished(
    bytes32 indexed intentHash,
    uint64 indexed destination,
    bytes route,
    address creator,
    address prover,
    uint64 deadline,
    uint256 nativeAmount,
    TokenAmount[] tokens
)
Emitted when a new intent is published.

IntentFunded

event IntentFunded(
    bytes32 indexed intentHash,
    address indexed funder,
    bool fullyFunded
)
Emitted when an intent is funded (fully or partially).

IntentWithdrawn

event IntentWithdrawn(
    bytes32 indexed intentHash,
    address indexed claimant
)
Emitted when rewards are withdrawn to a claimant.

IntentRefunded

event IntentRefunded(
    bytes32 indexed intentHash,
    address indexed refundee
)
Emitted when rewards are refunded.

IntentTokenRecovered

event IntentTokenRecovered(
    bytes32 indexed intentHash,
    address indexed creator,
    address token
)
Emitted when tokens are recovered from a vault.

Build docs developers (and LLMs) love