This directory provides example scripts for calling depositForBurn and receiveMessage on Solana Devnet.
For more information see our developer documentation.
-
Install the Solana CLI and spl-token CLI.
-
Install dependencies:
npm install
-
Create a local Devnet wallet (if needed), get some Devnet SOL, and create a USDC token account:
solana-keygen new -o devnetUser.json solana-keygen pubkey devnetUser.json solana airdrop -u devnet 5 devnetUser.json spl-token create-account -u devnet --owner devnetUser.json 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
-
Copy over the
.env.examplefile.cp .env.example .env
-
Set the new token account created in Prerequisites to the
USER_TOKEN_ACCOUNTvariable in .env. -
Get some Devnet USDCSOL and/or EVM testnet USDC to transfer: https://faucet.circle.com/.
-
Set an EVM address in hex to the
REMOTE_EVM_ADDRESSvariable in .env. This address will receive the minted tokens on the destination chain (AVAX by default, destination can be changed withREMOTE_EVM_DOMAINenv var).
Set REMOTE_EVM_PRIVATE_KEY and REMOTE_EVM_RPC_URL variables in .env.
The below commands will run the depositForBurn, attestation fetching, and receiveMessage steps.
# Bridge Solana to EVM
npm run bridge-v2 sol2evm -- --amount 100 --maxFee 1 --minFinalityThreshold 1000
# Bridge EVM to Solana
npm run bridge-v2 evm2sol -- --amount 100 --maxFee 1 --minFinalityThreshold 1000# Bridge Solana to EVM
npm run bridge-v2 sol2evm -- --amount 100 --maxFee 0 --minFinalityThreshold 2000
# Bridge EVM to Solana
npm run bridge-v2 evm2sol -- --amount 100 --maxFee 0 --minFinalityThreshold 2000To utilize hook functionality, set DESTINATION_CALLER in the env vars and pass the hookData arg when calling the above scripts.
npm run bridge-v2 sol2evm -- --amount 100 --maxFee 1 --minFinalityThreshold 1000 --hookData 0x1234The rent for the MessageSentEvent Account can be reclaimed after a period of 5 days.
npm run bridge-v2 reclaim --attestation <ATTESTATION> --destinationMessage <DESTINATION_MESSAGE> --messageSentEventAccount <MESSAGE_SENT_EVENT_ACCOUNT>To initiate a depositForBurn instruction from Solana to another chain follow these steps:
-
Call depositForBurn script:
npm run depositForBurn
-
The output
messageandattestationcan be used to callreceiveMessageon the destination blockchain CCTP contracts: https://developers.circle.com/stablecoins/docs/transfer-usdc-on-testnet-from-ethereum-to-avalanche.
-
Call
depositForBurnon an EVM chain with adestinationDomainof 5 for Solana, and amintRecipientof the desired user token account on Solana Devnet (you can use the account created in Prerequisites). This address must be decoded from base58 to hex first using something like this. For more info and scripts to help with calling depositForBurn on a different chain, see our EVM docs here. -
Set
MESSAGE_HEXandATTESTATION_HEXin .env from the transaction in step 1. These can be easily found by calling the messages API:https://iris-api-sandbox.circle.com/messages/${sourceDomainId}/${depositForBurnTxHash}. -
Set the token account used for the
mintRecipientin step 1 to theUSER_TOKEN_ACCOUNTvariable in .env. -
Call receiveMessage script:
npm run receiveMessage