logoDeveloper Hub

Build Your First Avalanche L1

This tutorial walks you through the process of using Avalanche-CLI to create an Avalanche L1, deploy it on a local network, and add to Core wallet.

The first step of learning Avalanche L1 development is learning to use Avalanche-CLI.

Installation

The fastest way to install the latest Avalanche-CLI binary is by running the install script:

curl -sSfL https://raw.githubusercontent.com/ava-labs/avalanche-cli/main/scripts/install.sh | sh -s

The binary installs inside the ~/bin directory. If the directory doesn't exist, it will be created.

You can run all of the commands in this tutorial by calling ~/bin/avalanche.

You can also add the command to your system path by running:

export PATH=~/bin:$PATH

If you add it to your path, you should be able to call the program anywhere with just avalanche. To add it to your path permanently, add an export command to your shell initialization script (ex: .bashrc or .zshrc).

For more detailed installation instructions, see Avalanche-CLI Installation.

Create Your Avalanche L1 Configuration

This tutorials teaches you how to create an Ethereum Virtual Machine (EVM) based Avalanche L1. To do so, you use Subnet-EVM, Avalanche's Avalanche L1 fork of the EVM. It supports airdrops, custom fee tokens, configurable gas parameters, and multiple stateful precompiles. To learn more, take a look at Subnet-EVM. The goal of your first command is to create a Subnet-EVM configuration.

The Avalanche L1 command suite provides a collection of tools for developing and deploying Avalanche L1s.

The Avalanche L1 Creation Wizard walks you through the process of creating your Avalanche L1. To get started, first pick a name for your Avalanche L1. This tutorial uses myblockchain, but feel free to substitute that with any name you like. Once you've picked your name, run:

avalanche blockchain create myblockchain

The following sections walk through each question in the wizard.

Choose Your VM

Use the arrow keys to navigate: 
? Which Virtual Machine would you like to use?: 
 Subnet-EVM
    Custom VM
    Explain the difference

Select Subnet-EVM.

Choose Your Validator Manager Contract

Choose either Proof of Authority (PoA) or Proof of Stake (PoS) as your consensus mechanism.

? Which validator management type would you like to use in your blockchain?: 
 Proof Of Authority
    Proof Of Stake
    Explain the difference

For this tutorial, select Proof of Authority (PoA).

For more info, reference the Validator Manager Contracts.

Enter Owner Address for Validator Manager Contract

This address will be able to add and remove validators from your Avalanche L1. You can either use an existing key or create a new one.

Which address do you want to enable as controller of ValidatorManager contract?: 
 Get address from an existing stored key (created from avalanche key create or avalanche key import)
    Custom

In addition to being the PoA owner, this address will also be the owner of the ProxyAdmin contract of the Validator Manager's TransparentUpgradeableProxy. This address will be able to upgrade the Validator Manager implementation through upgrading the proxy.

Enter EVM Configuration

The CLI provides some default values to help you get started. You can choose to use these defaults or customize them. These values include things such as airdrop amount, gas fees, and gas limits.

? Do you want to use default values for the Blockchain configuration?: 
 I want to use defaults for a test environment
    I want to use defaults for a production environment
    I don't want to use default values
    Explain the difference

For this tutorial, select I want to use defaults for a test environment.

Enter Your Avalanche L1's ChainID

 Chain ID: 

Choose a positive integer for your EVM-style ChainID.

In production environments, this ChainID needs to be unique and not shared with any other chain. You can visit chainlist to verify that your selection is unique. Because this is a development Avalanche L1, feel free to pick any number. Stay away from well-known ChainIDs such as 1 (Ethereum) or 43114 (Avalanche C-Chain) as those may cause issues with other tools.

Token Symbol

 Token Symbol: 

Enter a string to name your Avalanche L1's native token. The token symbol doesn't necessarily need to be unique. Example token symbols are AVAX, JOE, and BTC.

Wrapping Up

If all worked successfully, the command prints:

 Successfully created blockchain configuration

You've successfully created your first Avalanche L1 configuration. Now it's time to deploy it.

Deploying Avalanche L1s Locally

To deploy your Avalanche L1, run:

avalanche blockchain deploy myblockchain

Make sure to substitute the name of your Avalanche L1 if you used a different one than myblockchain.

? Choose a network for the operation: 
 Local Network
    Devnet
    Etna Devnet
    Fuji Testnet
    Mainnet

Next, select Local Network.

This command boots a five node Avalanche network on your machine. It needs to download the latest versions of AvalancheGo and Subnet-EVM. The command may take a couple minutes to run.

Note: If you run bash on your shell and are running Avalanche-CLI on ARM64 on Mac, you will require Rosetta 2 to be able to deploy Avalanche L1s locally. You can download Rosetta 2 using softwareupdate --install-rosetta .

If all works as expected, the command output should look something like this:

avalanche blockchain deploy myblockchain
 
# output
 Local Network
Deploying [myblockchain] to Local Network
Backend controller started, pid: 53868, output at: /Users/l1-developer/.avalanche-cli/runs/server_20241120_183019/avalanche-cli-backend.log
 
Booting Network. Wait until healthy...
Node logs directory: /Users/l1-developer/.avalanche-cli/runs/network_20241120_183020/node<i>/logs
Network ready to use.
 
Deploying Blockchain. Wait until network acknowledges...
 
Blockchain ready to use
 
+--------------------------------------------------------------------------------------------------------------------------------+
|                                                          MYBLOCKCHAIN                                                          |
+---------------+----------------------------------------------------------------------------------------------------------------+
| Name          | myblockchain                                                                                                   |
+---------------+----------------------------------------------------------------------------------------------------------------+
| VM ID         | qDNV9vtxZYYNqm7TN1mYBuaaknLdefDbFK8bFmMLTJQJKaWjV                                                              |
+---------------+----------------------------------------------------------------------------------------------------------------+
| VM Version    | v0.6.12                                                                                                        |
+---------------+----------------------------------------------------------------------------------------------------------------+
| Validation    | Proof Of Authority                                                                                             |
+---------------+--------------------------+-------------------------------------------------------------------------------------+
| Local Network | ChainID                  | 888                                                                                 |
|               +--------------------------+-------------------------------------------------------------------------------------+
|               | SubnetID                 | 26eqgD4Kt1MvTKXC9BDjEwBAfhcBcHCKj2EXjR2UuFpSWoAHhw                                  |
|               +--------------------------+-------------------------------------------------------------------------------------+
|               | Owners (Threshold=1)      | P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p                                     |
|               +--------------------------+-------------------------------------------------------------------------------------+
|               | BlockchainID (CB58)      | 2BK8CKA4Vfvi69TBTc5GW94JQ9nPiL8xPpPNeeckb9UFSPYedD                                  |
|               +--------------------------+-------------------------------------------------------------------------------------+
|               | BlockchainID (HEX)       | 0x9b1ca24503853edd6b6ac083f78adc8c36df74a85027e1b30535cc1032287805                  |
|               +--------------------------+-------------------------------------------------------------------------------------+
|               | RPC Endpoint             | http://127.0.0.1:9650/ext/bc/2BK8CKA4Vfvi69TBTc5GW94JQ9nPiL8xPpPNeeckb9UFSPYedD/rpc |
+---------------+--------------------------+-------------------------------------------------------------------------------------+
 
+---------------------------+
|           TOKEN           |
+--------------+------------+
| Token Name   | TST Token |
+--------------+------------+
| Token Symbol | TST       |
+--------------+------------+
 
+------------------------------------------------------------------------------------------------------------------------------------+
|                                                      INITIAL TOKEN ALLOCATION                                                      |
+---------------------+------------------------------------------------------------------+---------------+---------------------------+
| DESCRIPTION         | ADDRESS AND PRIVATE KEY                                          | AMOUNT (OWEN) | AMOUNT (WEI)              |
+---------------------+------------------------------------------------------------------+---------------+---------------------------+
| Main funded account | 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC                       | 1000000       | 1000000000000000000000000 |
| ewoq                | 56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 |               |                           |
+---------------------+------------------------------------------------------------------+---------------+---------------------------+
 
+-----------------------------------------------------------------------------------------------------------------+
|                                                 SMART CONTRACTS                                                 |
+-----------------------+--------------------------------------------+--------------------------------------------+
| DESCRIPTION           | ADDRESS                                    | DEPLOYER                                   |
+-----------------------+--------------------------------------------+--------------------------------------------+
| PoA Validator Manager | 0x0C0DEbA5E0000000000000000000000000000000 |                                            |
+-----------------------+--------------------------------------------+--------------------------------------------+
| Transparent Proxy     | 0x0Feedc0de0000000000000000000000000000000 |                                            |
+-----------------------+--------------------------------------------+--------------------------------------------+
| Proxy Admin           | 0xC0fFEE1234567890aBCdeF1234567890abcDef34 | 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC |
+-----------------------+--------------------------------------------+--------------------------------------------+
 
+----------------------------------------------------------------------+
|                      INITIAL PRECOMPILE CONFIGS                      |
+------------+-----------------+-------------------+-------------------+
| PRECOMPILE | ADMIN ADDRESSES | MANAGER ADDRESSES | ENABLED ADDRESSES |
+------------+-----------------+-------------------+-------------------+
| Warp       | n/a             | n/a               | n/a               |
+------------+-----------------+-------------------+-------------------+
 
+-------------------------------------------------------------------------------------------------+
|                                      MYBLOCKCHAIN RPC URLS                                      |
+-----------+-------------------------------------------------------------------------------------+
| Localhost | http://127.0.0.1:9650/ext/bc/2BK8CKA4Vfvi69TBTc5GW94JQ9nPiL8xPpPNeeckb9UFSPYedD/rpc |
+-----------+-------------------------------------------------------------------------------------+
 
+--------------------------------------------------------------------------+
|                                   NODES                                  |
+-------+------------------------------------------+-----------------------+
| NAME  | NODE ID                                  | LOCALHOST ENDPOINT    |
+-------+------------------------------------------+-----------------------+
| node1 | NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg | http://127.0.0.1:9650 |
+-------+------------------------------------------+-----------------------+
| node2 | NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ | http://127.0.0.1:9652 |
+-------+------------------------------------------+-----------------------+
| node3 | NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN | http://127.0.0.1:9654 |
+-------+------------------------------------------+-----------------------+
| node4 | NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu | http://127.0.0.1:9656 |
+-------+------------------------------------------+-----------------------+
| node5 | NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5 | http://127.0.0.1:9658 |
+-------+------------------------------------------+-----------------------+
 
+-------------------------------------------------------------------------------------------------------+
|                                           WALLET CONNECTION                                           |
+-----------------+-------------------------------------------------------------------------------------+
| Network RPC URL | http://127.0.0.1:9650/ext/bc/2BK8CKA4Vfvi69TBTc5GW94JQ9nPiL8xPpPNeeckb9UFSPYedD/rpc |
+-----------------+-------------------------------------------------------------------------------------+
| Network Name    | myblockchain                                                                        |
+-----------------+-------------------------------------------------------------------------------------+
| Chain ID        | 888                                                                                 |
+-----------------+-------------------------------------------------------------------------------------+
| Token Symbol    | TST                                                                                |
+-----------------+-------------------------------------------------------------------------------------+
| Token Name      | TST Token                                                                          |
+-----------------+-------------------------------------------------------------------------------------+

You can use the deployment details to connect to and interact with your Avalanche L1. Now it's time to interact with it.

Interacting with Your Avalanche L1

You can use the value provided by Browser Extension connection details to connect to your Avalanche L1 with Core, MetaMask, or any other wallet.

Note

To allow API calls from other machines, use --http-host=0.0.0.0 in the config.

Browser Extension connection details (any node URL from above works):
RPC URL:          http://127.0.0.1:9650/ext/bc/2BK8CKA4Vfvi69TBTc5GW94JQ9nPiL8xPpPNeeckb9UFSPYedD/rpc
Funded address:   0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC with 1000000 (10^18) - private key: 56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027
Network name:     myblockchain
Chain ID:         888
Currency Symbol:  TUTORIAL

This tutorial uses Core.

Importing the Test Private Key

This address derives from a well-known private key. Anyone can steal funds sent to this address. Only use it on development networks that only you have access to. If you send production funds to this address, attackers may steal them instantly.

First, you need to import your airdrop private key into Core.

In the Accounts screen, select the Imported tab. Click on Import private key.

Here, enter the private key. Import the well-known private key 0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027.

Next, rename the Core account to prevent confusion. On the Imported tab, click on the pen icon next to your account. Rename the account DO NOT USE -- Public test key to prevent confusion with any personal wallets.

Rename Account

Rename Account

Connect to the Avalanche L1

Next, you need to add your Avalanche L1 to Core's networks.

In the Core Extension click, See All Networks and then select the + icon in the top right.

Add network

Enter your Avalanche L1's details, found in the output of your avalanche blockchain deploy command, into the form and click Save.

Add network 2

If all worked as expected, your balance should read 1 million tokens. Your Avalanche L1 is ready for action. You might want to try to Deploy a Smart Contract on Your Subnet-EVM Using Remix and Core.

Avalanche L1 in Core

Next Steps

After you feel comfortable with this deployment flow, try deploying smart contracts on your chain with Remix, Hardhat, or Foundry. You can also experiment with customizing your Avalanche L1 by addingprecompiles or adjusting the airdrop.

Once you've developed a stable Avalanche L1 you like, see Create an EVM Avalanche L1 on Fuji Testnet to take your Avalanche L1 one step closer to production.

FAQ

How is the Avalanche L1 ID (SubnetID) determined upon creation?

The Avalanche L1 ID (SubnetID) is the hash of the transaction that created the Avalanche L1.

Last updated on

On this page

Edit on Github