Cross-chain interoperability is a cornerstone of modern blockchain development, enabling seamless transfer of assets and data across disparate networks. Chainlink’s Cross-Chain Interoperability Protocol (CCIP) provides a secure, standardized way to move tokens and arbitrary data between blockchains. This guide walks you through using Chainlink CCIP to transfer both tokens and text data from Avalanche Fuji to Ethereum Sepolia, with support for paying transaction fees in either LINK or native gas tokens like AVAX.
Whether you're building decentralized applications (dApps), cross-chain bridges, or multi-chain DeFi protocols, mastering CCIP empowers your smart contracts to communicate securely and efficiently across ecosystems.
Prerequisites
Before diving into the implementation, ensure you meet the following requirements:
- Familiarity with writing, compiling, deploying, and funding smart contracts using Solidity, MetaMask, and the Remix IDE.
- Testnet tokens on both Avalanche Fuji (AVAX and LINK) and Ethereum Sepolia (ETH).
- Understanding of ERC20 token standards and contract interactions.
- Access to the CCIP Directory to verify supported tokens and chain selectors.
- A funded wallet with CCIP-BnM test tokens — used in this tutorial for cross-chain transfers.
👉 Get started with cross-chain development tools and resources here.
How CCIP Enables Cross-Chain Transfers
Chainlink CCIP allows developers to send messages, transfer tokens, and execute logic across blockchains in a trust-minimized manner. The protocol abstracts complex routing, security, and execution layers, letting smart contracts focus on application logic.
In this tutorial, we’ll use a single contract that:
- Sends tokens and string data between chains.
- Supports fee payments in LINK or native gas (e.g., AVAX).
- Implements allowlists for enhanced security.
This dual-payment model gives developers flexibility: use LINK for predictable fee estimation or native tokens for user convenience.
Core Contract Functionality
The example contract ProgrammableTokenTransfers
inherits from CCIPReceiver
and OwnerIsCreator
, ensuring secure message receipt and ownership control. It supports two primary functions:
sendMessagePayLINK()
– Pay CCIP fees in LINK.sendMessagePayNative()
– Pay fees in native gas (AVAX).
Both functions trigger cross-chain messages containing:
- A string message (e.g., "Hello World!")
- Token amount (e.g., 0.001 CCIP-BnM)
- Destination chain identifier (chain selector)
Security is enforced via:
- Allowlisted destination/source chains
- Verified sender addresses
- OnlyRouter access control (ensuring only Chainlink routers can deliver messages)
Step-by-Step Deployment Guide
1. Deploy the Sender Contract on Avalanche Fuji
- Open Remix IDE and load the contract code.
- Switch MetaMask to Avalanche Fuji Testnet.
- In Remix, select Injected Provider - MetaMask under Deploy & Run Transactions.
Provide these parameters during deployment:
- Router Address:
0xF694E193200268f9a4868e4Aa017A0118C9a8177
- LINK Contract Address:
0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846
- Router Address:
- Deploy the contract and note its address.
2. Fund and Configure the Sender Contract
- Transfer 0.002 CCIP-BnM and 70 LINK (for fee testing) to the deployed contract.
In Remix, call
allowlistDestinationChain()
with:_destinationChainSelector
:16015286601757825753
(Ethereum Sepolia)allowed
:true
This enables outbound messaging to Sepolia.
3. Deploy the Receiver Contract on Ethereum Sepolia
- Switch MetaMask to Ethereum Sepolia.
Deploy the same contract again using:
- Router Address:
0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59
- LINK Contract Address:
0x779877A7B0D9E8603169DdbD7836e478b4624789
- Router Address:
- Note the receiver contract address.
4. Secure the Receiver Contract
Call these functions in order:
allowlistSourceChain(14767482510784806043, true)
– Allows messages from Avalanche Fuji.allowlistSender([Sender_Contract_Address_On_Fuji], true)
– Whitelists your sender contract.
These steps prevent unauthorized message delivery.
Transfer Tokens & Data Paying Fees in LINK
Use this method when you want predictable fee costs denominated in LINK.
Steps:
- Ensure your sender contract has sufficient LINK balance (≥70 LINK recommended).
In Remix, call
sendMessagePayLINK()
with:_destinationChainSelector
:16015286601757825753
_receiver
: Your receiver contract address on Sepolia_text
:"Hello World!"
_token
:0xD21341536c5cF5EB1bcb58f6723cE26e8D8E90e4
(CCIP-BnM on Fuji)_amount
:1000000000000000
(equals 0.001 tokens)
- Confirm the transaction in MetaMask.
Verification:
- Use the CCIP Explorer to track your message by transaction hash.
Once status shows “Success,” check the receiver contract:
- Call
getLastReceivedMessageDetails()
in Remix. You should see:
- Message ID matching the explorer
- Text:
"Hello World!"
- Token amount:
1000000000000000
- Correct CCIP-BnM token address on Sepolia
- Call
👉 Explore real-time cross-chain message tracking tools now.
Transfer Tokens & Data Paying Fees in Native Gas (AVAX)
This approach uses native AVAX for fees, simplifying user experience by avoiding dependency on LINK.
Steps:
- Fund your sender contract with at least 0.2 AVAX.
- Call
sendMessagePayNative()
with identical parameters as above.
Note: The key difference is _feeTokenAddress
is set to address(0)
, signaling native gas usage.
- Confirm transaction and monitor via CCIP Explorer.
Even though fees are paid in AVAX, they are internally priced in LINK — node operators receive compensation in LINK regardless of payment method.
Frequently Asked Questions (FAQ)
Q: What is Chainlink CCIP?
A: Chainlink Cross-Chain Interoperability Protocol (CCIP) is an open standard enabling secure movement of data and tokens across blockchains. It powers cross-chain dApps, bridges, and asset transfers with built-in security and decentralization.
Q: Can I transfer multiple tokens in one message?
A: Yes! While this example sends one token, the tokenAmounts
array supports multiple EVMTokenAmount
entries, allowing batch transfers of different ERC20 tokens.
Q: Why do I need to allowlist chains and senders?
A: Allowlisting prevents unauthorized access and replay attacks. It ensures only trusted sources can send or receive messages, enhancing contract security.
Q: Are fees always denominated in LINK?
A: Yes — even when paying in native gas (like AVAX), the fee amount is calculated in LINK equivalents. This ensures consistent compensation for oracle operators.
Q: Can I receive messages back from Sepolia to Fuji?
A: Absolutely. The contract is bidirectional. After deploying both sides, you can initiate transfers in either direction by configuring the corresponding allowlists.
Q: Is this contract production-ready?
A: No — this is an educational example using hardcoded values and un-audited code. For production use, integrate dynamic configuration, error handling, and formal audits.
Key Code Components Explained
Building the CCIP Message
The _buildCCIPMessage()
function constructs an EVM2AnyMessage
struct containing:
- ABI-encoded receiver address
- Encoded string data
- Token array with address and amount
- Extra arguments: gas limit (
200,000
) and out-of-order execution enabled - Fee token: either LINK address or
address(0)
for native gas
Best practice: Compute extraArgs
off-chain to adapt to network conditions and future upgrades.
Receiving Messages Securely
The _ccipReceive()
function processes incoming messages only if:
- The call comes from the official Chainlink router (
onlyRouter
modifier). - Source chain and sender are allowlisted (
onlyAllowlisted
modifier). - Data is properly decoded from bytes to usable types (string, address, etc.).
Received data is stored in state variables and emitted via MessageReceived
event for easy off-chain monitoring.
Final Thoughts
Mastering Chainlink CCIP unlocks powerful capabilities for building truly interoperable blockchain applications. By supporting both LINK and native gas fee payments, developers gain flexibility without sacrificing security.
As multi-chain ecosystems grow, tools like CCIP become essential infrastructure for DeFi, NFTs, gaming, and enterprise solutions.
👉 Start building cross-chain applications with advanced developer tools today.
Core Keywords: Chainlink CCIP, cross-chain token transfer, CCIP tutorial, pay CCIP fees in LINK, pay CCIP fees in native gas, programmable token transfer, blockchain interoperability, EVM cross-chain messaging