CCIP v1.5.0 TokenPool Contract API Reference

TokenPool

The TokenPool contract is an abstract base class that defines common functionality for all token pools within the CCIP ecosystem. A token pool acts as an isolated location for holding tokens and executing token-specific logic, especially as tokens move across chains in a cross-chain interoperability setup. The contract implements validation mechanisms to ensure that tokens are securely transferred, burned, or locked when they are transferred between blockchains.

Errors

CallerIsNotARampOnRouter

error CallerIsNotARampOnRouter(address caller)

ZeroAddressNotAllowed

error ZeroAddressNotAllowed()

SenderNotAllowed

error SenderNotAllowed(address sender)

AllowListNotEnabled

error AllowListNotEnabled()

NonExistentChain

error NonExistentChain(uint64 remoteChainSelector)

ChainNotAllowed

error ChainNotAllowed(uint64 remoteChainSelector)

CursedByRMN

error CursedByRMN()

ChainAlreadyExists

error ChainAlreadyExists(uint64 chainSelector)

InvalidSourcePoolAddress

error InvalidSourcePoolAddress(bytes sourcePoolAddress)

InvalidToken

error InvalidToken(address token)

Unauthorized

error Unauthorized(address caller)

Events

Locked

event Locked(address sender, uint256 amount)

Burned

event Burned(address sender, uint256 amount)

Released

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

Minted

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

ChainAdded

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

ChainConfigured

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

ChainRemoved

event ChainRemoved(uint64 remoteChainSelector)

RemotePoolSet

event RemotePoolSet(uint64 remoteChainSelector, bytes previousPoolAddress, bytes remotePoolAddress)

AllowListAdd

event AllowListAdd(address sender)

AllowListRemove

event AllowListRemove(address sender)

RouterUpdated

event RouterUpdated(address oldRouter, address newRouter)

Structs

ChainUpdate

struct ChainUpdate {
  uint64 remoteChainSelector;
  bool allowed;
  bytes remotePoolAddress;
  bytes remoteTokenAddress;
  struct RateLimiter.Config outboundRateLimiterConfig;
  struct RateLimiter.Config inboundRateLimiterConfig;
}
NameTypeDescription
remoteChainSelectoruint64Remote chain selector.
allowedboolWhether the chain should be enabled.
remotePoolAddressbytesAddress of the remote pool, ABI encoded in the case of a remote EVM chain.
remoteTokenAddressbytesAddress of the remote token, ABI encoded in the case of a remote EVM chain.
outboundRateLimiterConfigRateLimiter.ConfigOutbound rate limited config, meaning the rate limits for all of the onRamps for the given chain.
inboundRateLimiterConfigRateLimiter.ConfigInbound rate limited config, meaning the rate limits for all of the offRamps for the given chain.

RemoteChainConfig

struct RemoteChainConfig {
  struct RateLimiter.TokenBucket outboundRateLimiterConfig;
  struct RateLimiter.TokenBucket inboundRateLimiterConfig;
  bytes remotePoolAddress;
  bytes remoteTokenAddress;
}
NameTypeDescription
outboundRateLimiterConfigRateLimiter.TokenBucketOutbound rate limited config, meaning the rate limits for all of the onRamps for the given chain.
inboundRateLimiterConfigRateLimiter.TokenBucketInbound rate limited config, meaning the rate limits for all of the offRamps for the given chain.
remotePoolAddressbytesAddress of the remote pool, ABI encoded in the case of a remote EVM chain.
remoteTokenAddressbytesAddress of the remote token, ABI encoded in the case of a remote EVM chain.

Variables

i_token

IERC20 i_token

The bridgeable token that is managed by this pool.

i_rmnProxy

address i_rmnProxy

The address of the RMN proxy.

i_allowlistEnabled

bool i_allowlistEnabled

The immutable flag that indicates if the pool is access-controlled.

Mappings

s_allowList

struct EnumerableSet.AddressSet s_allowList

A set of addresses allowed to trigger lockOrBurn as original senders. Only takes effect if i_allowlistEnabled is true.

s_router

contract IRouter s_router

The address of the router.

s_remoteChainSelectors

struct EnumerableSet.UintSet s_remoteChainSelectors

A set of allowed chain selectors.

s_remoteChainConfigs

mapping(uint64 => struct TokenPool.RemoteChainConfig) s_remoteChainConfigs

s_rateLimitAdmin

address s_rateLimitAdmin

The address of the rate limiter admin. Can be address(0) if none is configured.

Functions

constructor

constructor(contract IERC20 token, address[] allowlist, address rmnProxy, address router) internal

getRmnProxy

function getRmnProxy() public view returns (address rmnProxy)

Gets the RMN proxy address.

Return Values

NameTypeDescription
rmnProxyaddressAddress of RMN proxy.

isSupportedToken

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

Returns if the token pool supports the given token.

Parameters

NameTypeDescription
tokenaddressThe address of the token.

Return Values

NameTypeDescription
[0]booltrue if the token is supported.

getToken

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

Gets the IERC20 token that this pool can lock or burn.

Return Values

NameTypeDescription
tokenIERC20The IERC20 token.

getRouter

function getRouter() public view returns (address router)

Gets the pool's Router.

Return Values

NameTypeDescription
routeraddressThe pool's Router.

setRouter

function setRouter(address newRouter) public

Sets the pool's Router.

Parameters

NameTypeDescription
newRouteraddressThe new Router address.

supportsInterface

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

Signals which version of the pool interface is supported.

_validateLockOrBurn

function _validateLockOrBurn(struct Pool.LockOrBurnInV1 lockOrBurnIn) internal

Validates the lock or burn input for correctness.

Parameters

NameTypeDescription
lockOrBurnInstruct Pool.LockOrBurnInV1The input to validate.

_validateReleaseOrMint

function _validateReleaseOrMint(struct Pool.ReleaseOrMintInV1 releaseOrMintIn) internal

Validates the release or mint input for correctness.

Parameters

NameTypeDescription
releaseOrMintInstruct Pool.ReleaseOrMintInV1The input to validate.

getRemotePool

function getRemotePool(uint64 remoteChainSelector) public view returns (bytes)

Gets the pool address on the remote chain.

Parameters

NameTypeDescription
remoteChainSelectoruint64Remote chain selector.

getRemoteToken

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

Gets the token address on the remote chain.

Parameters

NameTypeDescription
remoteChainSelectoruint64Remote chain selector.

setRemotePool

function setRemotePool(uint64 remoteChainSelector, bytes remotePoolAddress) external

Sets the remote pool address for a given chain selector.

Parameters

NameTypeDescription
remoteChainSelectoruint64The remote chain selector.
remotePoolAddressbytesThe address of the remote pool.

isSupportedChain

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

Checks whether a remote chain is supported in the token pool.

Parameters

NameTypeDescription
remoteChainSelectoruint64Remote chain selector.

Return Values

NameTypeDescription
[0]booltrue if the chain is supported by the pool.

getSupportedChains

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

Gets the list of allowed chains.

Return Values

NameTypeDescription
[0]uint64[]List of allowed chains.

applyChainUpdates

function applyChainUpdates(ChainUpdate[] calldata chains) external virtual onlyOwner

Sets the permissions for a list of chain selectors. The senders for these chains must be allowed on the Router to interact with this pool.

Parameters

NameTypeDescription
chainsChainUpdate[] calldataA list of chains and their permission status & rate limits.

setRateLimitAdmin

function setRateLimitAdmin(address rateLimitAdmin) external onlyOwner

Sets the rate limiter admin address.

Parameters

NameTypeDescription
rateLimitAdminaddressThe new rate limiter admin address.

getRateLimitAdmin

function getRateLimitAdmin() external view returns (address)

Gets the rate limiter admin address.

Return Values

NameTypeDescription
rateLimitAdminaddressThe current rate limiter admin address.

getCurrentOutboundRateLimiterState

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

Gets the token bucket state for outbound rate limits.

Parameters

NameTypeDescription
remoteChainSelectoruint64Remote chain selector.

Return Values

NameTypeDescription
[0]RateLimiter.TokenBucketThe current state of the outbound rate limiter.

getCurrentInboundRateLimiterState

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

Gets the token bucket state for inbound rate limits.

Parameters

NameTypeDescription
remoteChainSelectoruint64Remote chain selector.

Return Values

NameTypeDescription
[0]RateLimiter.TokenBucketThe current state of the inbound rate limiter.

setChainRateLimiterConfig

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

Sets the chain rate limiter config.

Parameters

NameTypeDescription
remoteChainSelectoruint64Remote chain selector.
outboundConfigRateLimiter.ConfigOutbound rate limiter configuration.
inboundConfigRateLimiter.ConfigInbound rate limiter configuration.

getAllowListEnabled

function getAllowListEnabled() external view returns (bool)

Gets whether the allowList functionality is enabled.

Return Values

NameTypeDescription
[0]booltrue if the allowList is enabled.

getAllowList

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

Gets the list of allowed addresses in the allowlist.

Return Values

NameTypeDescription
[0]address[]List of allowed addresses.

applyAllowListUpdates

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

Applies updates to the allow list.

Parameters

NameTypeDescription
removesaddress[]Addresses to remove from the allowlist.
addsaddress[]Addresses to add to the allowlist.

Get the latest Chainlink content straight to your inbox.