API Version: v0.2.1 Not using latest version (v0.2.3)

MockEvm2EvmOffRamp v0.2.1 API Reference

MockEvm2EvmOffRamp

MockEvm2EvmOffRamp simulates the destination chain component of CCIP's cross-chain message delivery system. This contract handles token releases and message execution in a test environment.

Errors

CanOnlySimulatorCall

error CanOnlySimulatorCall()

Thrown when a non-simulator address attempts to call restricted functions.

ReceiverError

error ReceiverError(bytes error)

Thrown when the CCIP receiver execution fails.

TokenHandlingError

error TokenHandlingError(bytes error)

Thrown when token release or minting operations encounter non-rate-limiting errors.

UnsupportedToken

error UnsupportedToken(IERC20 token)

Thrown when attempting to interact with a token that doesn't have an associated pool.

Structs

DynamicConfig

struct DynamicConfig {
  uint32 permissionLessExecutionThresholdSeconds;
  address router;
  address priceRegistry;
  uint16 maxNumberOfTokensPerMsg;
  uint32 maxDataBytes;
  uint32 maxPoolReleaseOrMintGas;
}

Configuration parameters that can be updated during contract operation:

• permissionLessExecutionThresholdSeconds - Waiting time before manual execution is enabled • router - Router address • priceRegistry - Price registry address • maxNumberOfTokensPerMsg - Maximum number of ERC20 token transfers per message • maxDataBytes - Maximum payload data size in bytes • maxPoolReleaseOrMintGas - Maximum gas for token pool releaseOrMint calls

Variables

i_sourceChainSelector

uint64 internal immutable i_sourceChainSelector

The chain selector identifying the source chain for this off-ramp.

s_ccipLocalSimulator

address internal s_ccipLocalSimulator

The address of the local CCIP simulator controlling this off-ramp.

s_dynamicConfig

DynamicConfig internal s_dynamicConfig

Current dynamic configuration settings for the off-ramp.

s_poolsBySourceToken

EnumerableMapAddresses.AddressToAddressMap private s_poolsBySourceToken

Maps source token addresses to their corresponding token pool addresses.

Functions

constructor

constructor(
    address ccipLocalSimulator,
    DynamicConfig memory dynamicConfig,
    RateLimiter.Config memory config,
    uint64 sourceChainSelector,
    address[] memory sourceTokens,
    address[] memory pools
) AggregateRateLimiter(config)

Initializes the off-ramp with simulator settings, configuration parameters, and token pool mappings.

Parameters:

ParameterTypeDescription
ccipLocalSimulatoraddressAddress of the CCIP simulator
dynamicConfigDynamicConfigInitial dynamic configuration settings
configRateLimiter.ConfigRate limiter configuration
sourceChainSelectoruint64Chain selector for the source chain
sourceTokensaddress[]Array of source token addresses
poolsaddress[]Array of corresponding token pool addresses

executeSingleMessage

function executeSingleMessage(
    Internal.EVM2EVMMessage memory message,
    bytes[] memory offchainTokenData
) external

Processes a single cross-chain message by releasing tokens and executing the receiver's callback.

Parameters:

ParameterTypeDescription
messageInternal.EVM2EVMMessageThe cross-chain message to process
offchainTokenDatabytes[]Token data provided by off-chain DON

getPoolBySourceToken

function getPoolBySourceToken(IERC20 sourceToken) public view returns (IPool)

Retrieves the token pool associated with a source token.

Parameters:

ParameterTypeDescription
sourceTokenIERC20The source token address to look up

Returns:

TypeDescription
IPoolThe token pool contract for the source token

_releaseOrMintTokens

function _releaseOrMintTokens(
    Client.EVMTokenAmount[] memory sourceTokenAmounts,
    bytes memory originalSender,
    address receiver,
    bytes[] memory sourceTokenData,
    bytes[] memory offchainTokenData
) internal returns (Client.EVMTokenAmount[] memory)

Handles the release or minting of tokens through token pools. This function includes safety measures against malicious tokens and rate limiting.

Parameters:

ParameterTypeDescription
sourceTokenAmountsClient.EVMTokenAmount[]List of tokens and amount values to be released/minted
originalSenderbytesThe message sender
receiveraddressThe address that will receive the tokens
sourceTokenDatabytes[]Array of token data returned by token pools on the source chain
offchainTokenDatabytes[]Array of token data fetched offchain by the DON

Returns:

TypeDescription
Client.EVMTokenAmount[]Array of processed token amounts and addresses

Get the latest Chainlink content straight to your inbox.