API Version: v1.5.1

CCIP v1.5.1 TokenPool Contract API Reference

TokenPool

An abstract contract that provides base functionality for managing cross-chain token operations in CCIP. It handles token decimals across different chains, rate limiting, and access control.

Git Source

Inherits:

Events

AllowListAdd

Emitted when an address is added to the allowlist via applyAllowListUpdates.

event AllowListAdd(address sender);

Parameters

NameTypeIndexedDescription
senderaddressNoThe address that was added to the allowlist

AllowListRemove

Emitted when an address is removed from the allowlist via applyAllowListUpdates.

event AllowListRemove(address sender);

Parameters

NameTypeIndexedDescription
senderaddressNoThe address that was removed from the allowlist

Burned

Emitted when tokens are burned by the pool.

event Burned(address indexed sender, uint256 amount);

Parameters

NameTypeIndexedDescription
senderaddressYesThe address initiating the burn operation
amountuint256NoThe amount of tokens burned

ChainAdded

Emitted when a new chain is configured in the pool via applyChainUpdates.

event ChainAdded(
  uint64 remoteChainSelector,
  bytes remoteToken,
  RateLimiter.Config outboundRateLimiterConfig,
  RateLimiter.Config inboundRateLimiterConfig
);

Parameters

NameTypeIndexedDescription
remoteChainSelectoruint64NoThe identifier of the newly added chain
remoteTokenbytesNoThe token address on the remote chain
outboundRateLimiterConfigRateLimiter.ConfigNoRate limit configuration for outbound transfers
inboundRateLimiterConfigRateLimiter.ConfigNoRate limit configuration for inbound transfers

ChainConfigured

Emitted when a chain's configuration is updated via setChainRateLimiterConfig or setChainRateLimiterConfigs.

event ChainConfigured(
  uint64 remoteChainSelector,
  RateLimiter.Config outboundRateLimiterConfig,
  RateLimiter.Config inboundRateLimiterConfig
);

Parameters

NameTypeIndexedDescription
remoteChainSelectoruint64NoThe identifier of the chain being configured
outboundRateLimiterConfigRateLimiter.ConfigNoUpdated rate limit configuration for outbound transfers
inboundRateLimiterConfigRateLimiter.ConfigNoUpdated rate limit configuration for inbound transfers

ChainRemoved

Emitted when a chain is removed from the pool's configuration via applyChainUpdates.

event ChainRemoved(uint64 remoteChainSelector);

Parameters

NameTypeIndexedDescription
remoteChainSelectoruint64NoThe identifier of the chain being removed

Locked

Emitted when tokens are locked by the pool.

event Locked(address indexed sender, uint256 amount);

Parameters

NameTypeIndexedDescription
senderaddressYesThe address initiating the lock operation
amountuint256NoThe amount of tokens locked

Minted

Emitted when tokens are minted by the pool.

event Minted(address indexed sender, address indexed recipient, uint256 amount);

Parameters

NameTypeIndexedDescription
senderaddressYesThe address initiating the mint operation
recipientaddressYesThe address receiving the minted tokens
amountuint256NoThe amount of tokens minted

RemotePoolAdded

Emitted when a new remote pool is added via addRemotePool or applyChainUpdates.

event RemotePoolAdded(uint64 indexed remoteChainSelector, bytes remotePoolAddress);

Parameters

NameTypeIndexedDescription
remoteChainSelectoruint64YesThe identifier of the chain for the new pool
remotePoolAddressbytesNoThe address of the newly added pool

Released

Emitted when tokens are released by the pool.

event Released(address indexed sender, address indexed recipient, uint256 amount);

Parameters

NameTypeIndexedDescription
senderaddressYesThe address initiating the release operation
recipientaddressYesThe address receiving the released tokens
amountuint256NoThe amount of tokens released

RemotePoolRemoved

Emitted when a remote pool is removed via removeRemotePool.

event RemotePoolRemoved(uint64 indexed remoteChainSelector, bytes remotePoolAddress);

Parameters

NameTypeIndexedDescription
remoteChainSelectoruint64YesThe identifier of the chain for the pool
remotePoolAddressbytesNoThe address of the removed pool

RouterUpdated

Emitted when the router address is updated via setRouter.

event RouterUpdated(address oldRouter, address newRouter);

Parameters

NameTypeIndexedDescription
oldRouteraddressNoThe previous router contract address
newRouteraddressNoThe new router contract address

RateLimitAdminSet

Emitted when the rate limit administrator is changed via setRateLimitAdmin.

event RateLimitAdminSet(address rateLimitAdmin);

Parameters

NameTypeIndexedDescription
rateLimitAdminaddressNoThe new rate limit administrator address

Errors

AllowListNotEnabled

error AllowListNotEnabled();

CallerIsNotARampOnRouter

error CallerIsNotARampOnRouter(address caller);

ChainAlreadyExists

error ChainAlreadyExists(uint64 chainSelector);

Parameters

NameTypeDescription
chainSelectoruint64The selector of the chain that already exists

ChainNotAllowed

error ChainNotAllowed(uint64 remoteChainSelector);

CursedByRMN

error CursedByRMN();

InvalidDecimalArgs

error InvalidDecimalArgs(uint8 expected, uint8 actual);

Parameters

NameTypeDescription
expecteduint8The expected number of decimals
actualuint8The actual number of decimals provided

InvalidRemoteChainDecimals

error InvalidRemoteChainDecimals(bytes sourcePoolData);

Parameters

NameTypeDescription
sourcePoolDatabytesThe invalid decimal configuration data

InvalidRemotePoolForChain

error InvalidRemotePoolForChain(uint64 remoteChainSelector, bytes remotePoolAddress);

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector being queried
remotePoolAddressbytesThe invalid pool address

InvalidSourcePoolAddress

error InvalidSourcePoolAddress(bytes sourcePoolAddress);

InvalidToken

error InvalidToken(address token);

Parameters

NameTypeDescription
tokenaddressThe address of the invalid token

MismatchedArrayLengths

error MismatchedArrayLengths();

NonExistentChain

error NonExistentChain(uint64 remoteChainSelector);

OverflowDetected

error OverflowDetected(uint8 remoteDecimals, uint8 localDecimals, uint256 remoteAmount);

Parameters

NameTypeDescription
remoteDecimalsuint8The decimals on the remote chain
localDecimalsuint8The decimals on the local chain
remoteAmountuint256The amount that caused the overflow

PoolAlreadyAdded

error PoolAlreadyAdded(uint64 remoteChainSelector, bytes remotePoolAddress);

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector where the pool exists
remotePoolAddressbytesThe address of the already existing pool

SenderNotAllowed

error SenderNotAllowed(address sender);

Unauthorized

error Unauthorized(address caller);

Parameters

NameTypeDescription
calleraddressThe address that attempted the action

ZeroAddressNotAllowed

error ZeroAddressNotAllowed();

Structs

ChainUpdate

Configuration data for adding or updating a chain.

struct ChainUpdate {
  uint64 remoteChainSelector;
  bytes[] remotePoolAddresses;
  bytes remoteTokenAddress;
  RateLimiter.Config outboundRateLimiterConfig;
  RateLimiter.Config inboundRateLimiterConfig;
}

RemoteChainConfig

Internal configuration for a remote chain.

struct RemoteChainConfig {
  RateLimiter.TokenBucket outboundRateLimiterConfig;
  RateLimiter.TokenBucket inboundRateLimiterConfig;
  bytes remoteTokenAddress;
  EnumerableSet.Bytes32Set remotePools;
}

State Variables

i_token

The token managed by this pool. Currently supports one token per pool.

IERC20 internal immutable i_token;

i_tokenDecimals

The number of decimals for the managed token.

uint8 internal immutable i_tokenDecimals;

i_rmnProxy

The Risk Management Network (RMN) proxy address.

address internal immutable i_rmnProxy;

i_allowlistEnabled

Flag indicating if the pool uses access control.

bool internal immutable i_allowlistEnabled;

s_allowlist

Set of addresses authorized to initiate cross-chain operations.

EnumerableSet.AddressSet internal s_allowlist;

s_router

The CCIP Router contract address.

IRouter internal s_router;

s_remoteChainSelectors

Set of authorized chain selectors for cross-chain operations.

EnumerableSet.UintSet internal s_remoteChainSelectors;

s_remoteChainConfigs

Configuration for each remote chain, including rate limits and token details.

mapping(uint64 remoteChainSelector => RemoteChainConfig) internal s_remoteChainConfigs;

s_remotePoolAddresses

Maps hashed pool addresses to their original form for verification.

mapping(bytes32 poolAddressHash => bytes poolAddress) internal s_remotePoolAddresses;

s_rateLimitAdmin

The address authorized to manage rate limits.

address internal s_rateLimitAdmin;

Functions

_applyAllowListUpdates

Internal version of applyAllowListUpdates to allow for reuse in the constructor.

function _applyAllowListUpdates(address[] memory removes, address[] memory adds) internal;

Parameters

NameTypeDescription
removesaddress[]Array of addresses to remove from the allowlist
addsaddress[]Array of addresses to add to the allowlist

_calculateLocalAmount

Calculates the local amount based on the remote amount and decimals.

This function protects against overflows. If there is a transaction that hits the overflow check, it is probably incorrect as that means the amount cannot be represented on this chain. If the local decimals have been wrongly configured, the token issuer could redeploy the pool with the correct decimals and manually re-execute the CCIP tx to fix the issue.

function _calculateLocalAmount(uint256 remoteAmount, uint8 remoteDecimals) internal view virtual returns (uint256);

Parameters

NameTypeDescription
remoteAmountuint256The amount on the remote chain.
remoteDecimalsuint8The decimals of the token on the remote chain.

Returns

NameTypeDescription
<none>uint256The local amount.

_checkAllowList

Internal function to verify if a sender is authorized when allowlist is enabled.

function _checkAllowList(address sender) internal view;

Parameters

NameTypeDescription
senderaddressThe address to check for permission

_consumeInboundRateLimit

Internal function to consume rate limiting capacity for incoming transfers.

function _consumeInboundRateLimit(uint64 remoteChainSelector, uint256 amount) internal;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector for the source chain
amountuint256The amount of tokens being transferred

_consumeOutboundRateLimit

Internal function to consume rate limiting capacity for outgoing transfers.

function _consumeOutboundRateLimit(uint64 remoteChainSelector, uint256 amount) internal;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector for the destination chain
amountuint256The amount of tokens being transferred

_encodeLocalDecimals

Internal function to encode the local token's decimals for cross-chain communication.

function _encodeLocalDecimals() internal view virtual returns (bytes memory);

Returns

TypeDescription
bytesABI-encoded decimal places of the local token

_onlyOffRamp

Checks whether remote chain selector is configured on this contract, and if the msg.sender is a permissioned offRamp for the given chain on the Router.

function _onlyOffRamp(uint64 remoteChainSelector) internal view;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to validate authorization for

_onlyOnRamp

Checks whether remote chain selector is configured on this contract, and if the msg.sender is a permissioned onRamp for the given chain on the Router.

function _onlyOnRamp(uint64 remoteChainSelector) internal view;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to validate authorization for

_parseRemoteDecimals

Internal function to decode the decimal configuration received from a remote chain.

function _parseRemoteDecimals(bytes memory sourcePoolData) internal view virtual returns (uint8);

Parameters

NameTypeDescription
sourcePoolDatabytesThe encoded decimal configuration data

Returns

TypeDescription
uint8The number of decimals used on the remote chain

_setRateLimitConfig

Internal function to update rate limit configuration for a chain.

function _setRateLimitConfig(
  uint64 remoteChainSelector,
  RateLimiter.Config memory outboundConfig,
  RateLimiter.Config memory inboundConfig
) internal;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to configure
outboundConfigRateLimiter.ConfigRate limit configuration for outgoing transfers
inboundConfigRateLimiter.ConfigRate limit configuration for incoming transfers

_setRemotePool

Internal function to add a pool address to the allowed remote token pools for a chain. Called during chain configuration and when adding individual remote pools.

function _setRemotePool(uint64 remoteChainSelector, bytes memory remotePoolAddress) internal;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to add the pool for
remotePoolAddressbytesThe address of the remote pool (encoded to support non-EVM chains)

_validateLockOrBurn

Internal function to validate lock or burn operations.

function _validateLockOrBurn(Pool.LockOrBurnInV1 calldata lockOrBurnIn) internal;

_validateReleaseOrMint

Internal function to validate release or mint operations.

function _validateReleaseOrMint(Pool.ReleaseOrMintInV1 calldata releaseOrMintIn) internal;

addRemotePool

Adds a new pool address for a remote chain.

function addRemotePool(uint64 remoteChainSelector, bytes calldata remotePoolAddress) external onlyOwner;

applyAllowListUpdates

Apply updates to the allow list.

function applyAllowListUpdates(address[] calldata removes, address[] calldata adds) external onlyOwner;

Parameters

NameTypeDescription
removesaddress[]The addresses to be removed.
addsaddress[]The addresses to be added.

applyChainUpdates

Updates chain configurations in bulk.

function applyChainUpdates(
  uint64[] calldata remoteChainSelectorsToRemove,
  ChainUpdate[] calldata chainsToAdd
) external virtual onlyOwner;

constructor

constructor(IERC20 token, uint8 localTokenDecimals, address[] memory allowlist, address rmnProxy, address router);

Parameters

NameTypeDescription
tokenIERC20The token to be managed by this pool
localTokenDecimalsuint8The token's decimal places on this chain
allowlistaddress[]Initial set of authorized addresses (if any)
rmnProxyaddressThe Risk Management Network proxy address
routeraddressThe CCIP Router contract address

getAllowList

Gets the allowed addresses.

function getAllowList() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]The allowed addresses.

getAllowListEnabled

Returns whether allowlist functionality is active.

function getAllowListEnabled() external view returns (bool);

Returns

NameTypeDescription
<none>booltrue is enabled, false if not.

getCurrentInboundRateLimiterState

Returns the current state of inbound rate limiting for a chain.

function getCurrentInboundRateLimiterState(
  uint64 remoteChainSelector
) external view returns (RateLimiter.TokenBucket memory);

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to get rate limiter state for

Returns

TypeDescription
RateLimiter.TokenBucketCurrent state of the inbound rate limiter

getCurrentOutboundRateLimiterState

Returns the current state of outbound rate limiting for a chain.

function getCurrentOutboundRateLimiterState(
  uint64 remoteChainSelector
) external view returns (RateLimiter.TokenBucket memory);

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to get rate limiter state for

Returns

TypeDescription
RateLimiter.TokenBucketCurrent state of the outbound rate limiter

getRateLimitAdmin

Returns the current rate limit administrator address.

function getRateLimitAdmin() external view returns (address);

getRemotePools

Returns the configured pool addresses for a remote chain.

function getRemotePools(uint64 remoteChainSelector) public view returns (bytes[] memory);

Parameters

NameTypeDescription
remoteChainSelectoruint64The remote chain identifier

Returns

TypeDescription
bytes[]Array of encoded pool addresses on remote chain

getRemoteToken

Returns the token address on a remote chain.

function getRemoteToken(uint64 remoteChainSelector) public view returns (bytes memory);

Parameters

NameTypeDescription
remoteChainSelectoruint64The remote chain identifier

Returns

TypeDescription
bytesThe encoded token address on the remote chain

getRmnProxy

Returns the Risk Management Network proxy address.

function getRmnProxy() public view returns (address rmnProxy);

Returns

TypeDescription
addressThe RMN proxy contract address

getRouter

Returns the current router address.

function getRouter() public view returns (address router);

Returns

TypeDescription
addressThe CCIP router contract address

getSupportedChains

Returns all configured chain selectors.

function getSupportedChains() public view returns (uint64[] memory);

Returns

TypeDescription
uint64[]Array of configured chain selectors

getToken

Returns the token managed by this pool.

function getToken() public view returns (IERC20 token);

Returns

TypeDescription
IERC20The token contract address

getTokenDecimals

Returns the number of decimals for the managed token.

function getTokenDecimals() public view virtual returns (uint8 decimals);

Returns

TypeDescription
uint8The number of decimal places for the token

isRemotePool

Verifies if a pool address is configured for a remote chain.

function isRemotePool(uint64 remoteChainSelector, bytes calldata remotePoolAddress) public view returns (bool);

Parameters

NameTypeDescription
remoteChainSelectoruint64The remote chain identifier
remotePoolAddressbytesThe pool address to verify

Returns

TypeDescription
boolTrue if the pool is configured for the chain

isSupportedChain

Checks if a chain is configured in the pool.

function isSupportedChain(uint64 remoteChainSelector) public view returns (bool);

Returns

TypeDescription
boolTrue if the chain is configured in the pool

isSupportedToken

Checks if a given token is supported by this pool.

function isSupportedToken(address token) public view virtual returns (bool);

Parameters

NameTypeDescription
tokenaddressThe token address to check

Returns

TypeDescription
boolTrue if the token is supported by this pool

removeRemotePool

Removes a pool address from a remote chain's configuration.

function removeRemotePool(uint64 remoteChainSelector, bytes calldata remotePoolAddress) external onlyOwner;

Parameters

NameTypeDescription
remoteChainSelectoruint64The chain selector to remove the pool from
remotePoolAddressbytesThe address of the pool to remove

setChainRateLimiterConfig

Sets the chain rate limiter config.

function setChainRateLimiterConfig(
  uint64 remoteChainSelector,
  RateLimiter.Config memory outboundConfig,
  RateLimiter.Config memory inboundConfig
) external;

Parameters

NameTypeDescription
remoteChainSelectoruint64The remote chain selector for which the rate limits apply.
outboundConfigRateLimiter.ConfigThe new outbound rate limiter config, meaning the onRamp rate limits for the given chain.
inboundConfigRateLimiter.ConfigThe new inbound rate limiter config, meaning the offRamp rate limits for the given chain.

setChainRateLimiterConfigs

Updates rate limit configurations for multiple chains.

function setChainRateLimiterConfigs(
  uint64[] calldata remoteChainSelectors,
  RateLimiter.Config[] calldata outboundConfigs,
  RateLimiter.Config[] calldata inboundConfigs
) external;

Parameters

NameTypeDescription
remoteChainSelectorsuint64[]The chain selectors to configure
outboundConfigsRateLimiter.Config[]The new outbound rate limiter configs, meaning the onRamp rate limits for the given chains
inboundConfigsRateLimiter.Config[]The new inbound rate limiter configs, meaning the offRamp rate limits for the given chains

setRateLimitAdmin

Sets the address authorized to manage rate limits.

function setRateLimitAdmin(address rateLimitAdmin) external onlyOwner;

setRouter

Updates the router contract address.

function setRouter(address newRouter) public onlyOwner;

Parameters

NameTypeDescription
newRouteraddressThe new router contract address

supportsInterface

Implements ERC165 interface detection.

function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier to check

Returns

TypeDescription
boolTrue if the contract implements the interface

Rate Limiting

Get the latest Chainlink content straight to your inbox.