Intent Utilities
Types
Call
Represents a contract call to be executed.TokenAmount
Represents an ERC20 token and amount.Route
Defines the execution route on the destination chain.Reward
Defines the reward for intent fulfillment.Intent
Complete intent structure combining route and reward.Encoding Functions
encodeRoute
Encodes a route object into ABI-encoded bytes.route: Route object to encode
encodeReward
Encodes a reward object into ABI-encoded bytes.reward: Reward object to encode
encodeIntent
Encodes a complete intent into ABI-encoded bytes.intent: Complete intent object to encode
Hashing Functions
hashIntent
Generates cryptographic hashes for an intent and its components.intent: Intent to hash
routeHash: Keccak256 hash of encoded routerewardHash: Keccak256 hash of encoded rewardintentHash: Combined hash of destination, routeHash, and rewardHash
Vault Address Prediction
intentVaultAddress
Predicts the CREATE2 vault address for an intent.intentSourceAddress: Address of the IntentSource contractintent: Intent object to calculate vault address for
Encoding Utilities
Helper functions for encoding common contract function calls.encodeTransfer
Encodes an ERC20 transfer function call.to: Recipient addressvalue: Amount to transfer
transfer(address,uint256)
Example:
encodeTransferNative
Encodes a native token transfer function call.to: Recipient addressvalue: Amount of native tokens to transfer
transferNative(address,uint256)
encodeTransferPayable
Encodes a payable transfer function call.to: Recipient addressvalue: Amount to transfer
transferPayable(address,uint256)
encodeIdentifier
Generates a unique identifier hash from counter and chain ID.counter: Counter valuechainid: Chain ID
Type Conversion Utilities
TheTypeCasts utility class provides functions for converting between Ethereum addresses and bytes32 values.
TypeCasts Class
addressToBytes32
Converts an Ethereum address to bytes32 format.address: Ethereum address (20 bytes)
bytes32ToAddress
Converts bytes32 back to an Ethereum address.bytes32: bytes32 value (32 bytes)
addressesToBytes32Array
Converts multiple addresses to bytes32 array.addresses: Array of Ethereum addresses
bytes32ArrayToAddresses
Converts bytes32 array back to addresses.bytes32Array: Array of bytes32 values