TokenMessengerV2 contract with hook data to call the CctpForwarder contract
on HyperEVM. This CCTP flow follows the same pattern as USDC transfers from
Ethereum to any other domain, except for the inclusion of hook data to call the
CctpForwarder contract on HyperEVM.
This guide does not provide full example code, you can find an example of
transfers from Ethereum in the
CCTP quickstart.
Note: Fast Transfers from Ethereum to HyperEVM incur a variable fee and a
small forwarding fee for transfers to HyperCore. Fast Transfer is the default
for transfers from Ethereum to HyperEVM.
Steps
Use the following steps to transfer USDC from Ethereum to HyperCore.Step 1. Get CCTP fees from the API
Query the CCTP API for the fees for transferring USDC from Ethereum to HyperCore. This value is passed to themaxFee parameter in the
depositForBurnWithHook transaction. The following is an example request to the
CCTP using source domain 0 (Ethereum) and destination domain 19 (HyperEVM):
Step 2. Calculate the USDC amounts minus fees
There is a variable fee to deposit USDC from Ethereum to HyperEVM and a small forwarding fee for the transfer to HyperCore. The CCTP fee is returned by the API in theminimumFee field (1_000 USDC subunits). The forwarding fee is
0.50 USC (0_500_000 subunits). For a 10 USDC transfer from Ethereum to
HyperCore, the total fee is 0.5001 USDC.
Step 3. Approve the USDC transfer
To allow theTokenMessengerV2 contract to transfer the USDC on your behalf,
you need to approve the transfer. This is done by calling the approve function
on the USDC contract.
You can see an example of this contract call in the
Ethereum CCTP V2 example on GitHub.
Step 4. Sign and broadcast a depositForBurnWithHook transaction on the TokenMessengerV2 contract
Create a depositForBurnWithHook transaction for the TokenMessengerV2
contract with the following parameters:
amount: The amount of USDC to transferdestinationDomain: 19 (HyperEVM)mintRecipient: The address of theCctpForwardercontract on HyperEVMdestinationCaller: The address of theCctpForwardercontract on HyperEVMmaxFee:0_501_000(from step 2)minFinalityThreshold:1000(Fast Transfer)hookData: The hook data to call theCctpForwardercontract on HyperEVM
hookData is the data to execute the forwarder to HyperCore. The following
is an example of the hook data:
hyperCoreDestinationDex is 0), deposits credit the perps
balance on HyperCore. To deposit to the spot balance, set
hyperCoreDestinationDex to 4294967295 (uint32 max value).