On Avalanche Mainnet
Deploy an Avalanche L1 to Avalanche Mainnet
Deploying an Avalanche L1 to Mainnet has many risks. Doing so safely requires a laser focus on security. This tutorial does its best to point out common pitfalls, but there may be other risks not discussed here.
This tutorial is an educational resource and provides no guarantees that following it results in a secure deployment. Additionally, this tutorial takes some shortcuts that aid the understanding of the deployment process at the expense of security. The text highlights these shortcuts and they shouldn't be used for a production deployment.
After managing a successful Avalanche L1 deployment on the Fuji Testnet
, you're ready to deploy your Avalanche L1 on Mainnet. If you haven't done so, first Deploy an Avalanche L1 on Testnet.
This tutorial shows how to do the following on Mainnet
.
- Deploy an Avalanche L1.
- Add a node as a validator to the Avalanche L1.
All IDs in this article are for illustration purposes only. They are guaranteed to be different in your own run-through of this tutorial.
Prerequisites
- An Avalanche node running and fully bootstrapped on
Mainnet
- Avalanche-CLI is installed on each validator node's box
- A Ledger device
- You've created an Avalanche L1 configuration and fully tested a Fuji Testnet Avalanche L1 deployment
Setting up Your Ledger
In the interest of security, all Avalanche-CLI Mainnet
operations require the use of a connected Ledger device. You must unlock your Ledger and run the Avalanche App. See How to Use Ledger for help getting set up.
Ledger devices support TX signing for any address inside a sequence automatically generated by the device.
By default, Avalanche-CLI uses the first address of the derivation, and that address needs funds to issue the TXs to create the Avalanche L1 and add validators.
To get the first Mainnet
address of your Ledger device, first make sure it is connected, unblocked, and running the Avalanche app. Then execute the key list
command:
The command prints the P-Chain address for Mainnet
, P-avax1ucykh6ls8thqpuwhg3vp8vvu6spg5e8tp8a25j
, and its balance.
You can use the key list
command to get any Ledger address in the derivation sequence by changing the index parameter from 0
to the one desired, or to a list of them (for example: 2
, or 0,4,7
). Also, you can ask for addresses on Mainnet
with the --mainnet
parameter, and local networks with the --local
parameter.
Funding the Ledger
A new Ledger device has no funds on the addresses it controls. You'll need to send funds to it by exporting them from C-Chain to the P-Chain using Core web connected to Core extension.
You can load the Ledger's C-Chain address in Core extension, or load in a different private key to Core extension, and then connect to Core web .
You can move test funds from the C-Chain to the P-Chain by clicking Stake on Core web , then Cross-Chain Transfer (find more details on this tutorial).
Deploy the Avalanche L1
To deploy the Avalanche L1, you will need some AVAX on the P-Chain.
For our Fuji example, we used our local machine as a bootstrap validator. However, since bootstrapping a node to Mainnet will take several hours, we will use an Avalanche node set up on an AWS server that is already bootstrapped to Mainnet for this example.
To check if the Avalanche node is done bootstrapping, ssh into the node and call info.isBootstrapped
by copying and pasting the following command:
If this returns true
, it means that the chain is bootstrapped and we will proceed to deploying our L1.
We will need to have the Avalanche node's NodeID, BLS public key and proof of possession. These can be obtained by ssh into the node itself and run the getNodeID
API specified here
To deploy the new Avalanche L1, with your Ledger unlocked and running the Avalanche app, run:
This is going to start a new prompt series.
This tutorial is about deploying to Mainnet
, so navigate with the arrow keys to Mainnet
and hit enter. The user is then asked to provide which private key to use for the deployment. Select a key to has P-Chain AVAX to pay for transaction fees.
After that, CLI shows the Mainnet
Ledger address used to fund the deployment:
Select No
to using local machine as a bootstrap validator on the blockchain.
Enter 1 as the number of bootstrap validators we will be setting up.
Select Yes
since we have already set up our Avalanche Node on AWS.
Next, we will enter the node's Node-ID:
And BLS public key and proof of possession:
Next, the CLI generates a CreateSubnet TX to create the Subnet and asks the user to sign it by using the Ledger.
This activates a Please review
window on the Ledger. Navigate to the Ledger's APPROVE
window by using the Ledger's right button, and then authorize the request by pressing both left and right buttons.
If the Ledger doesn't have enough funds, the user may see an error message:
If successful, the CLI next asks you to sign a CreateChain Tx. Once CreateChain Tx is signed, it will then ask you to sign ConvertSubnetToL1 Tx.
Well done. You have just created your own Avalanche L1 on Mainnet
.
You will be able to see information on the deployed L1 at the end of avalanche blockchain deploy
command:
To get your new Avalanche L1 information, there are two options:
- Call
avalanche blockchain describe
command or - Visit the Avalanche L1 Explorer. The search best works by blockchain ID, so in this example, enter
2U7vNdB78xTiN6QtZ9aetfKoGtQhfeEPQG6QZC8bpq8QMf4cDx
into the search box and you should see your shiny new blockchain information.
Add a Validator
Before proceeding to add a validator to our Avalanche L1, we will need to have the validator's NodeID, BLS public key and proof of possession. These can be obtained by ssh into the node itself and run the getNodeID
API specified here
To add a validator to an Avalanche L1, the owner of the key that acts as the controller of ValidatorManager contract specified in avalanche blockchain create
command above run:
Choose Mainnet
:
The CLI will show the Ledger address that will be used to pay for add validator tx:
Now enter the NodeID of the new validator to be added.
Next, enter the node's BLS public key and proof of possession.
Now, enter the amount of AVAX that you would like to allocate to the new validator.
The validator's balance is used to pay for continuous fee to the P-Chain. When this Balance reaches 0, the validator will be considered inactive and will no longer participate in validating the L1.
1 AVAX should last the validator about a month.
Sign the addValidatorTx with your Ledger:
This activates a Please review
window on the Ledger. Navigate to the Ledger's APPROVE
window by using the Ledger's right button, and then authorize the request by pressing both left and right buttons.
This might take a couple of seconds. After, it prints:
This means the node is now a validator on the given Avalanche L1 on Mainnet
!
Going Live
For the safety of your validators, you should setup dedicated API nodes to process transactions, but for test purposes, you can issue transactions directly to one of your validator's RPC interface.
Last updated on