Explore the integration of Chainlink to conduct USDC transfers between Avalanche Fuji and Ethereum Sepolia networks. This repository includes detailed instructions on setting up wallets, adding tokens, and deploying a contract to facilitate the cross-chain transfer of USDC using Chainlink's CCIP.
- Setup
- Adding LINK and USDC Tokens
- Smart Contract Deployment
- Interacting with the Contract
- Monitoring Transactions
- MetaMask Configuration:
- Ensure MetaMask is installed and set up for both Avalanche Fuji and Ethereum Sepolia.
- Add Fuji to MetaMask
- Sepolia details are available at Chainlink Documentation.
- Ensure MetaMask is installed and set up for both Avalanche Fuji and Ethereum Sepolia.
- Access the Remix IDE for smart contract deployment: Remix
- Set the environment to
Injected provider - MetaMask
and confirm connection to the Fuji network.
- Set the environment to
- LINK Token:
- Avalanche Fuji: LINK on Fuji
- Ethereum Sepolia: LINK on Sepolia
- USDC Token:
- Add USDC on Avalanche Fuji following instructions from Circle Developers
- Obtain LINK and AVAX for Fuji at Chainlink Faucets
- Additional LINK can be acquired from AllThatNode Faucet
- Contract Creation:
- In Remix, use the "FILE EXPLORER" to create a new file named
TransferUSDCBasic.sol
. - Copy the contract code from the provided snippet into this file.
- In Remix, use the "FILE EXPLORER" to create a new file named
- Compile and deploy the contract on the Avalanche Fuji network using MetaMask.
To allow the TransferUSDCBasic
contract to manage your USDC, you have two options for approval:
- Navigate to the Snowtrace Write Contract page.
- Connect your wallet.
- Under the
approve
function, enter:- spender: Your
TransferUSDCBasic.sol
contract address. - value: 100000 (equivalent to 0.1 USDC).
- spender: Your
- Click "Write" to submit the transaction.
- In Remix, ensure your
TransferUSDCBasic.sol
contract is deployed. - From the "Deploy & Run Transactions" panel:
- Select "IERC20" from the dropdown under "Contracts".
- Paste the USDC contract address (0x5425890298aed601595a70ab815c96711a31bc65) into the "At Address" field and click "At Address". Note: Do not deploy.
- Expand the contract methods and find the
approve
function:- spender: Address of your
TransferUSDCBasic.sol
contract. - value: 100000 (0.1 USDC).
- spender: Address of your
- Execute the transaction by clicking "Transact".
After approval, proceed with the USDC transfer:
- Navigate back to your deployed
TransferUSDCBasic.sol
contract in Remix. - Call the
transferUsdcToSepolia
function with the parameters:- _receiver: Your wallet address on the Ethereum Sepolia network.
- _amount: 100000 (0.1 USDC).
- Monitor the transaction in Remix and on the CCIP Explorer to ensure successful execution.
- Track the transaction ID and status using the CCIP Explorer.
- Verify USDC balances on both networks to confirm the transfer was successful.
While interacting with the TransferUSDCBasic
contract and executing transactions, you might encounter several issues. Below are some common problems along with troubleshooting tips:
- Symptoms: Transactions for approving or transferring USDC fail without executing.
- Potential Causes and Solutions:
- Insufficient Gas Fees: Ensure that your wallet has enough AVAX to cover the gas fees on the Avalanche Fuji testnet. You can obtain AVAX from Fuji faucets.
- Incorrect Contract Permissions: Double-check that the contract address used in the
approve
function is correct. Ensure that theTransferUSDCBasic
contract address is entered correctly.
- Symptoms: After executing the
transferUsdcToSepolia
function, the USDC does not appear in the destination wallet. - Potential Causes and Solutions:
- Network Delays: Transactions across networks may experience delays. Wait a few minutes and check again.
- Block Explorer Issues: Use a reliable block explorer like Snowtrace for Fuji and Sepolia Etherscan to verify the transactions and balances.
- Symptoms: After initiating a cross-chain transaction, the CCIP Explorer does not display any details about the transaction.
- Potential Causes and Solutions:
- Transaction Not Yet Indexed: Sometimes, transactions take a while to be indexed by explorers. Refresh the page or check back later to see if the transaction appears.
- Incorrect Transaction ID: Ensure you copied the correct transaction ID from Remix after executing the function.
- Symptoms: The balances displayed in Remix or on blockchain explorers do not reflect recent transactions or expected values.
- Potential Causes and Solutions:
- Failed Transactions: Check your wallet and block explorer histories to confirm that previous transactions (fund transfers, approvals) were successful.
- Refresh Data: Sometimes, interfaces do not update promptly. Refresh your wallet or the page of the blockchain explorer you are using.
- Symptoms: Errors pop up when trying to execute functions in the Remix IDE.
- Potential Causes and Solutions:
- Smart Contract Bugs: Review the contract code for any potential errors that could affect execution.
- Remix IDE Errors: Ensure that Remix is connected to the correct network and that the contract is properly deployed and verified on the network.
Watch our tutorial on YouTube for a step-by-step project walkthrough.