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 Subnet for <subnetName> (including the <>). You can choose whatever name you want, but I recommend using mysubnet as the name to avoid the need for some manual configuration.
To create a Subnet configuration run the following command
avalanche subnet create <subnetName>
For example:
avalanche subnet create mysubnet
You will be prompted a Wizard to set the Subnet 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:
@martineckardt ➜ /workspaces/avalanche-starter-kit (main) $ avalanche subnet create mysubnet✔ Subnet-EVM✔ Use latest release versionInstalling subnet-evm-v0.6.3...subnet-evm-v0.6.3 installation successfulcreating genesis for subnet mysubnetEnter your subnet's ChainId. It can be any positive integer.ChainId: 9999Select a symbol for your subnet's native tokenToken symbol: TOK✔ Low disk use / Low Throughput 1.5 mil gas/s (C-Chain's setting)✔ Airdrop 1 million tokens to the default ewoq address (do not use in production)✔ No✔ Yes✔ Yesgenerating stored key "cli-teleporter-deployer" for teleporter deploys (evm address, genesis balance) = (0x59560360Cb5EA935849C07af1952fF0910bA690D, 600000000000000000000)using latest teleporter version (v1.0.0)✓ Successfully created subnet configuration
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:
You can check at any time if the network is running by issuing the following command:
avalanche network status
If you don't start your network manually it will be automatically started when you deploy your first Subnet with the avalanche subnet deploy <subnetName> command.
This output includes the endpoints of your 5 nodes where you can connect to interact with your Subnet. You're running a Subnet-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: