- TokenTransfer Smart Contract
This contract contains the TokenTransfer
smart contract built using Solidity and Chainlink's Cross-Chain Interoperability Protocol (CCIP). The contract allows transferring tokens across multiple blockchains using Chainlink's router.
- Cross-Chain Token Transfer: Transfer ERC20 tokens across different blockchains using Chainlink's CCIP.
- Fee Payment Options: Supports paying fees with LINK tokens or native chain currency.
- Allowlisted Chains: Only transfers to specified allowlisted chains are allowed.
- Receiver Validation: Ensures the receiver address is valid before executing a transfer.
- Owner Access Control: The contract owner can manage allowlisted chains and execute transfers.
To use or develop this project, follow these steps:
-
Clone the repository:
git clone https://github.com/anurag-iitk/chainlink-ccip.git cd chainlink-ccip
-
Install Foundry:
Foundry is a blazing fast, portable, and modular toolkit for Ethereum application development written in Rust. If you don't have Foundry installed, you can install it here.
curl -L https://foundry.paradigm.xyz | bash foundryup
-
Install Dependencies:
forge install
-
Compile Contracts:
forge build
-
Run Tests:
forge test
-
forge script script/TokenTransfer.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key>
-
Deploy Contract: Deploy the contract to the desired blockchain network using your preferred method (Remix, Hardhat, etc.).
-
Add Allowlisted Chains: Use the
allowlistDestinationChain
function to specify the chains to which tokens can be transferred. -
Transfer Tokens:
- Use
transferTokensPayLINK
for transfers paying fees in LINK tokens. - Use
transferTokensPayNative
for transfers paying fees in the native chain currency.
- Use
-
Withdraw: Withdraw any remaining tokens or ETH in the contract using the
withdraw
orwithdrawToken
functions.
For more information, visit the project repository.