In order to send messages between two chains, we need to create a blockchain. In this guide, we will spin up a local Avalanche network that has it's own Primary Network (C-, P- and X-Chain) using the Avalanche CLI. Furthermore, we will create a blockchain in that Avalanche network, so we can send messages between the C-Chain and the newly created blockchain in the next chapters.
In the following commands, make sure to substitute the name of your Avalanche L1 for <subnetName> (including the <>). You can choose whatever name you want, but I recommend using myblockchain as the name to avoid the need for some manual configuration.
To create an Avalanche L1 configuration run the following command
For example:
You will be prompted a Wizard to set the Avalanche L1 config. For now, follow the default options where possible, except when asked for the Airdrop. Select the ewoq address for the airdrop. This address is the default address for the Avalanche test environments and is used for testing purposes.
For convenience, the private key 56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 of the default ewoq address is stored in the environment variable $PK.
PLACEHOLDER VIDEO subnet create
After the finishing, you should see something like this:
This command creates the config files genesis.json and sidecar.json inside: ~/.avalanche-cli/subnets/<subnetName>. If you want, you can retrieve the current config with the following command:
Now that we created our Avalanche L1 config, we need a network that will host that Avalanche L1. The following command will launch 5 nodes running locally:
The result should be something like this:
You can check at any time if the network is running by issuing the following command:
If you don't start your network manually it will be automatically started when you deploy your first Avalanche L1 with the avalanche subnet deploy <subnetName> command.
When prompted select Local Network to deploy on. After the deployment your should see something like this:
This output includes the endpoints of your 5 nodes where you can connect to interact with your Avalanche L1. You're running a Avalanche L1-EVM, this means you can use those RPC URLs to connect to EVM compatible wallet or tools.
Since the Avalanche Network is running in a Github Codespace the localhost (127.0.0.1) will only be accessible from inside the Codespace. Connecting your wallet using the localhost RPC URL will not work, since your wallet will be running on your computer, and not the local environment where the network is running (the Codespace cloud).
Therefore, we need to make the RPC-Endpoint publicly accessible. Click on the little antenna icon in the bottom bar of the Codespace:
There select the row with the port 9650 and right-click to open the port: