Contract responsibilities
- TokenMessengerV2: Entrypoint for crosschain USDC transfer. Routes messages to burn USDC on a source blockchain and mint USDC on a destination blockchain.
- TokenMessengerWithFees: Wrapper over
TokenMessengerV2that collects the fee upfront from a signed quote on the source blockchain, enabling upfront fees so the full amount mints on the destination blockchain. - MessageTransmitterV2: Generic message passing. Sends all messages on the source blockchain and receives all messages on the destination blockchain.
- TokenMinterV2: Responsible for minting and burning USDC. Contains blockchain-specific settings used by burners and minters.
- MessageV2: Provides helper functions for crosschain transfers, such as
bytes32ToAddressandaddressToBytes32, which are commonly used when bridging between EVM and non-EVM blockchains.
Gas optimization tip: If you’re writing your own integration, it’s more
gas-efficient to
include address conversion logic directly in your contract
rather than calling an external contract.
TokenMessengerV2
depositForBurn
Deposits and burns tokens from sender to be minted on destination domain. Minted tokens will be transferred tomintRecipient.
Note: There is a $10 million limit on the amount of USDC that can be burned
in a single CCTP transaction. If the amount exceeds this limit, the transaction
will revert. If you need to transfer more than this limit, break up your
transfers into multiple transactions.For Fast Transfers, you should always
check the remaining allowance
before initiating a transfer to ensure there is enough to complete your
transfer.
Example
Solidity
depositForBurnWithHook
Deposits and burns tokens from sender to be minted on destination domain, and emits a crosschain message with additional hook data appended. In addition to the standarddepositForBurn parameters, depositForBurnWithHook accepts a
dynamic-length hookData parameter, allowing you to include additional metadata
that can trigger custom logic on the destination blockchain.
Note: There is a $10 million limit on the amount of USDC that can be burned
in a single CCTP transaction. If the amount exceeds this limit, the transaction
will revert. If you need to transfer more than this limit, break up your
transfers into multiple transactions.For Fast Transfers, you should always
check the remaining allowance
before initiating a transfer to ensure there is enough to complete your
transfer.
getMinFeeAmount
Calculates and returns the minimum fee required for a given amount in a Standard Transfer. If the minimum fee (per unit ofburnToken) is non-zero, the
specified maxFee must be at least the returned minimum fee. Otherwise, the
burn will revert onchain.
Parameters
handleReceiveFinalizedMessage
Handles incoming message received by the local MessageTransmitter. For a burn message, mints the associated token to the requested recipient on the local domain. Validates the function sender is the local MessageTransmitter, and the remote sender is a registered remote TokenMessenger forremoteDomain.
This method is called for messages where finalityThresholdExecuted ≥ 2000
(Standard Transfer).
Parameters
handleReceiveUnfinalizedMessage
Handles incoming message received by the local MessageTransmitter. For a burn message, mints the associated token to the requested recipient on the local domain. Similar tohandleReceiveFinalizedMessage, but is called for messages
which are not finalized (finalityThresholdExecuted < 2000) such as Fast
Transfers.
Unlike handleReceiveFinalizedMessage, handleReceiveUnfinalizedMessage
processes messages with:
expirationBlock: IfexpirationBlock≤blockNumberon the destination domain, the message will revert and must be re-signed without the expiration block.feeExecuted: If nonzero, thefeeExecutedamount is minted to thefeeRecipient.
MessageTransmitterV2
receiveMessage
Receives message on destination blockchain by passing message and attestation.
Emits MessageReceived event. Messages with a given nonce can only be broadcast
successfully once for a pair of domains. The message body of a valid message is
passed to the specified recipient for further processing.
Parameters
Example
Solidity
sendMessage
Sends a message to the recipient on the destination domain. Emits a
MessageSent event which will be attested by Circle’s attestation service.
Parameters
TokenMessengerWithFees
depositForBurnWithFees
Collects the upfront fee from a signed quote, then burns tokens to be minted on
the destination domain. Pay the quoted fee as native currency (attach it as
msg.value) or in USDC (approve the contract to spend the quoted fee first).
Unlike TokenMessengerV2.depositForBurn, this method has no maxFee or
minFinalityThreshold parameter: fees are paid upfront, and the finality
threshold is inferred from whether the quote includes a PRE_FINALITY fee. If
the quote includes a FORWARD fee, a default cctp-forward hook is added
automatically.
The quote binds to the call parameters, so request it with the same amount,
destinationDomain, and burnToken you submit here, and without custom hook
data (this method applies the default hook). Otherwise the call reverts. To
submit custom hook data, use
depositForBurnWithHookAndFees instead.
Parameters
Example
Solidity
depositForBurnWithHookAndFees
Same as depositForBurnWithFees, but you supply custom hookData. When the
quote includes a FORWARD fee, hookData must contain a valid cctp-forward
hook; when it doesn’t include a FORWARD fee, hookData must not contain a
cctp-forward hook. For the hook structure, see
Forwarding Service hook format.
The quote binds to the call parameters, including the hook data, so request it
with the same hookData (and the same amount, destinationDomain,
burnToken, and destinationCaller) you submit here. A quote requested without
custom hook data is rejected by this method.
Parameters
getFee
Reads the total fee and fee token from a signed quote for the fee types this
wrapper supports (FORWARD and PRE_FINALITY). Use it to determine the amount
to attach or approve before you submit. This is a lightweight, type-based query;
signature, expiry, and payment are validated only during collection.
Parameters
Returns
Input types
Theclaim parameter bundles a signed quote with a per-call refundAddress,
the address to attribute any fee refund to.
QuoteClaim:
Upfront fees aren’t refunded today; the
refundAddress field is reserved for
potential future use. Pass an address you control so that it’s already in place
if the field is used later.ABI
TokenMessengerWithFees ABI
TokenMessengerWithFees ABI
TokenMessengerWithFees emit the standard
DepositForBurn and MessageSent
events from the underlying contracts.