How to Deploy Cross-Chain Tokens with Chainlink and thirdweb
How to Deploy Your Own Cross-Chain Token with Non-Fractionalized Liquidity Pools using Chainlink and Thirdweb
In this tutorial, we'll walk through the process of deploying your own cross-chain token using the new Cross-Chain Token (CCT) standard from Chainlink. The CCT standard allows you to create tokens that can exist on multiple blockchains simultaneously, with non-fractionalized liquidity pools on each chain.
By the end of this guide, you'll have deployed your own CCT token across two EVM chains (Sepolia and Arbitrum), set up the necessary liquidity pools, and sent a cross-chain token transfer using Chainlink's Cross-Chain Interoperability Protocol (CCIP).
You can follow along with the video tutorial here:
Prerequisites
- A Thirdweb account.
- A wallet like MetaMask to connect to Thirdweb.
- Some test funds on the ETH Sepolia and Arbitrum Sepolia testnets.
- The example repo cloned: https://github.com/smartcontractkit/thirdweb-ccip-v1_5/tree/main
Workflow Overview
- Deploy a token on each blockchain (ETH Sepolia and Arbitrum Sepolia)
- Deploy the token pools for each blockchain.
- Set up token configurations (grant mint/burn roles to pool, set pool as admin, link each pool to a token).
- Configure the pools to enable CCIP communication.
- Send tokens cross-chain from ETH Sepolia to Arbitrum Sepolia.
Step 1: Deploy the Tokens
We'll start by deploying an instance of the ERC677
token contract on both ETH Sepolia and Arbitrum Sepolia using the thirdweb dashboard.
- Open the ERC677 contract on the Thirdweb dashboard.
- Click "Deploy Now" and fill in the token details.
- Select "Sepolia" as the network and click "Deploy Now".
- Approve the transactions to deploy the contract and add it to your dashboard.
- Copy the token address for later.
- Repeat steps 2-5 but select "Arbitrum Sepolia" as the network this time.
Step 2: Deploy the Token Pools
Next, we'll deploy the token pool contracts that will manage the token liquidity on each chain.
- In your terminal, navigate to the cloned example repo directory
- Run the following command to deploy the pool contract on Sepolia:
npx thirdweb deploy -k youtThirdwebAPIKey
- Select the
BurnMintTokenPool
contract - Fill in the constructor parameters:
- Token address (use the Sepolia token address from step 1)
- Allowlist (leave empty)
- Proxy address (copy from
networks.json
in repo). - Router address (copy from
networks.json
in repo).
- Switch to Sepolia in MetaMask and click "Deploy Now"
- Open the token pool dashboard and copy the contract address
- Repeat steps 2-6 for Arbitrum Sepolia, using the Arbitrum Sepolia specific addresses.
Step 3: Configure Token Permissions
Now we need to grant the necessary permissions for the pool to manage the token on each chain. The example repo includes a script to automate this.
- Rename
.env.example
to.env
and fill in your RPC URLs and private key. Remember this is for testing purposes, so please keep your private key safe. - Run the following command to configure the Sepolia token:
forge script script/ConfigureTokenPermissions.s.sol:ConfigureTokenPermissions --rpc-url ${RPC_URL_SEPOLIA} --broadcast -vvvv --sig "run(address,address)" <SEPOLIA_TOKEN_ADDRESS> <SEPOLIA_POOL_ADDRESS>
- Repeat step 2 for the Arbitrum Sepolia token, using the Arbitrum Sepolia RPC URL and addresses
This will grant mint/burn roles to the pool, set the pool as the token admin, and link the pool to the token on each chain.
Step 4: Configure the Pools
The final configuration step is to enable the pools to communicate cross-chain using CCIP.
- Run the following command to configure the Sepolia pool:
forge script script/ConfigurePool.s.sol:ConfigurePool --rpc-url ${RPC_URL_SEPOLIA} --broadcast -vvvv --sig "run(address,uint256,address,address)" <SEPOLIA_POOL_ADDRESS> <ARBITRUM_CHAIN_ID> <ARBITRUM_POOL_ADDRESS> <ARBITRUM_TOKEN_ADDRESS>
- Repeat step 1 for the Arbitrum Sepolia pool, swapping the Sepolia and Arbitrum parameters
This links the origin pool address on Sepolia with the destination pool address on Arbitrum, and vice versa, using the CCIP router.
Step 5: Send Cross-Chain Tokens
Finally, we're ready to test a cross-chain token transfer from Sepolia to Arbitrum!
- Mint some tokens to your wallet on Sepolia using the token contract's
mint
function - Check that the tokens show up in MetaMask on Sepolia
- Run the following command to initiate the CCIP transfer:
forge script script/CCIPSend.s.sol:CCIPSend --rpc-url ${RPC_URL_SEPOLIA} --broadcast -vvvv --sig "run(address,uint256,address,uint256,address,address)" <RECIPIENT_ADDRESS> <ARBITRUM_CHAIN_ID> <SEPOLIA_TOKEN_ADDRESS> <AMOUNT_IN_WEI> <LINK_TOKEN_ADDRESS_SEPOLIA> <CCIP_ROUTER_ADDRESS_SEPOLIA>
- After 10-15 minutes, check your wallet on Arbitrum to see the transferred tokens!
The CCIPSend
script initiates a CCIP transfer, burning the tokens on Sepolia and minting them to the specified recipient on Arbitrum. You can track the progress of the message passing on the Chainlink CCIP Explorer.
Conclusion
Congratulations, you've now deployed your own cross-chain token using the Chainlink CCT standard! With fractionalized liquidity pools on each chain, your token can be used seamlessly across multiple networks.
The Thirdweb SDK and dashboard make it easy to deploy and manage your token contracts. Plus, you can use the code snippets in the thirdweb dashboard to integrate your token into your own dapp UI.
Cross-chain tokens open up exciting new possibilities for web3 applications. Try experimenting with more advanced use cases, like cross-chain DEX swaps or multi-chain NFT minting.
To dive deeper into how CCIP works under the hood, check out the Chainlink documentation. You can also customize the Solidity scripts in the example repo to fit your specific use case.
I hope you found this tutorial helpful! Feel free to reach out with any feedback or questions. Happy buidling!