Deploy a Remote Contract
Deploy the Token Remote on your own blockchain
To ensure the wrapped token is bridged into the destination chain (in this case, C-Chain) you'll need to deploy a remote contract that implements the IERC20Bridge
interface, as well as inheriting the properties of TeleporterTokenRemote
. In order for the bridged tokens to have all the normal functionality of a locally deployed ERC20 token, this remote contract must also inherit the properties of a standard ERC20
contract.
Save the Teleporter Registry Address
Most other environment variables we will need are already set in the devcontainer.
Get the Source Blockchain ID
Get the Source Blockchain ID
in hexidecimal format from the output of avalanche blockchain describe myblockchain
above, which in this example is the BlockchainID of your Avalanche L1:
Deploy the Remote Contract
Using the forge create
command, we will deploy the ERC20TokenRemote.sol
contract, passing in the following constructor arguments:
- Interchain Messaging Registry Address (for C-Chain)
- Interchain Messaging Manager (our funded address)
- Source Blockchain ID (hexidecimal representation of our Avalanche L1's Blockchain ID)
- Token Home Address (address of NativeTokenHome.sol deployed on Avalanche L1 in the last step)
- Token Name (input in the constructor of the wrapped token contract)
- Token Symbol (input in the constructor of the wrapped token contract)
- Token Decimals (uint8 integer representing number of decimal places for the ERC20 token being created. Most ERC20 tokens follow the Ethereum standard, which defines 18 decimal places.)
Save the Remote Contract Address
Note the address the remote contract was "Deployed to".
Register Remote Bridge with Home Bridge
After deploying the bridge contracts, you'll need to register the remote bridge by sending a dummy message using the registerWithHome
method. This message includes details which inform the Home Bridge about your destination blockchain and bridge settings, eg. initialReserveImbalance
.
Approve tokens for the Home Bridge contract
You can increase/decrease the numbers here as per your requirements. (All values are mentioned in wei)