From cea95d99dfb88bc961c7b8a9317d7261b035195e Mon Sep 17 00:00:00 2001 From: Andrea Vargas <43045203+Andyvargtz@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:04:21 +0000 Subject: [PATCH] add native minter precompile and env vars to intructions --- .../03-use-erc20-as-native-token.mdx | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/content/course/l1-tokenomics/03-multi-chain-ecosystems/03-use-erc20-as-native-token.mdx b/content/course/l1-tokenomics/03-multi-chain-ecosystems/03-use-erc20-as-native-token.mdx index 7d079cf..b8be738 100644 --- a/content/course/l1-tokenomics/03-multi-chain-ecosystems/03-use-erc20-as-native-token.mdx +++ b/content/course/l1-tokenomics/03-multi-chain-ecosystems/03-use-erc20-as-native-token.mdx @@ -20,9 +20,21 @@ Use the **Avalanche CLI** to create a new blockchain where you will deploy the E ```bash avalanche blockchain create myblockchain ``` +For this exercise, create a Proof of Authority blockchain that has Native Minter Precompile activated. This precompile is not activated NOT with the default test values, so make sure to go through the manual configuration of your L1 with the Avalanche-CLI. Add the deployer address as the `admin`for this, for convinience we will use the ewoq key that is already loaded as part of the Starter-Kit environment variables and which public key is 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC. Go with the default values for all other steps in the configuration process. +_Note: Having the Native Minter Precompile active and the correct admin rights assigned to the deployer is crucial for the rest of this lesson._ + ```bash avalanche blockchain deploy myblockchain ``` +Add all the environment variables. You can retrieve all your L1 detailes with `avalanche blockchain describe myblockchain` and `avalanche primary describe` for C-chain details. +```bash +export TELEPORTER_REGISTRY_C_CHAIN=0x... +export FUNDED_ADDRESS=0x... +export TELEPORTER_REGISTRY_L1=0x... +export L1_BLOCKCHAIN_ID_HEX=0x... +export C_CHAIN_BLOCKCHAIN_ID_HEX=0x... +``` + ### Deploy an ERC-20 Contract on C-Chain @@ -32,8 +44,15 @@ Use the **Avalanche CLI** to create a new blockchain where you will deploy the E You will deploy an ERC-20 token on the Avalanche C-Chain, which will later be transferred and used as the native token on the new L1. ```bash -forge create --rpc-url local-c --private-key $PK lib/avalanche-interchain-token-transfer/contracts/src/mocks/ExampleERC20Decimals.sol:ExampleERC20Decimals +forge create --rpc-url local-c --private-key $PK lib/avalanche-interchain-token-transfer/contracts/src/mocks/ExampleERC20Decimals.sol:ExampleERC20Decimals --constructor-args 18 +``` + +Save the newly created ERC20 address to the environment variables + +```bash +export $ERC20_HOME_C_CHAIN=0x... ``` + ### Deploy Interchain Token Transfer Contracts @@ -43,10 +62,22 @@ Set up the home and remote transferer contracts for transferring tokens between ```bash forge create --rpc-url local-c --private-key $PK lib/avalanche-interchain-token-transfer/contracts/src/TokenHome/ERC20TokenHome.sol:ERC20TokenHome --constructor-args $TELEPORTER_REGISTRY_C_CHAIN $FUNDED_ADDRESS $ERC20_HOME_C_CHAIN 18 ``` - + +Export to environment variables: + +```bash +export ERC20_HOME_TRANSFERER_C_CHAIN=0x... +``` + - `NativeTokenRemote` Contract on `myblockchain` ```bash -forge create --rpc-url myblockchain --private-key $PK lib/avalanche-interchain-token-transfer/contracts/src/TokenRemote/NativeTokenRemote.sol:NativeTokenRemote --constructor-args "($TELEPORTER_REGISTRY_L1, $FUNDED_ADDRESS, $C_CHAIN_BLOCKCHAIN_ID_HEX, $ERC20_HOME_TRANSFERER_C_CHAIN)" "EXMP.b" 100000000000000000000 0 false 0 +forge create --rpc-url myblockchain --private-key $PK lib/avalanche-interchain-token-transfer/contracts/src/TokenRemote/NativeTokenRemote.sol:NativeTokenRemote --constructor-args "($TELEPORTER_REGISTRY_L1, $FUNDED_ADDRESS, $C_CHAIN_BLOCKCHAIN_ID_HEX, $ERC20_HOME_TRANSFERER_C_CHAIN, 18)" "EXMP.b" 100000000000000000000 0 false 0 +``` + +Add to the enviroment variables + +```bash +export NATIVE_TOKEN_REMOTE_L1=0x... ``` _Note: When deploying the `NativeTokenRemote` contract on the L1, ensure that the **initial amount** matches the native token amount that was minted when the blockchain was created. This ensures consistency between the native token supply and the remote token counterpart._ @@ -64,9 +95,6 @@ To ensure that the `NativeTokenRemote` contract can mint native tokens on the L1 ```bash cast send --rpc-url myblockchain --private-key $PK 0x0200000000000000000000000000000000000001 "setEnabled(address)" $NATIVE_TOKEN_REMOTE_L1 ``` - -- `$NATIVE_TOKEN_REMOTE_L1`: The deployed address of the `NativeTokenRemote` contract on your L1. - Once this step is completed, the `NativeTokenRemote` contract will have the necessary permissions to mint native tokens when ERC-20 tokens are transferred from the C-Chain.