Skip to content

Commit

Permalink
add native minter precompile and env vars to intructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyvargtz committed Dec 5, 2024
1 parent 097df5f commit cea95d9
Showing 1 changed file with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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...
```

</Step>
<Step>
### Deploy an ERC-20 Contract on C-Chain
Expand All @@ -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...
```

</Step>
<Step>
### Deploy Interchain Token Transfer Contracts
Expand All @@ -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._
Expand All @@ -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.
</Step>
<Step>
Expand Down

0 comments on commit cea95d9

Please sign in to comment.