Skip to main content

Wallet Funding

The Ash CLI allows to interact with wallets and issue transactions with them on the Primary Network.


The Ash CLI uses plain-text private keys to interact with wallets. It should never be used on the mainnet. If you try do so, the command will fail with: AvalancheNetwork error: wallet creation is not allowed on network 'mainnet'.

To interact with wallets on the mainnet (e.g. to create Subnets and blockchains), you should use the Avalanche CLI which is compatible with Ledger devices.

In this tutorial, we will see how to create and fund a new wallet on:


See Installation for the Ash CLI installation instructions on your platform.

Configure the Ash CLI for your network

Prior to using the CLI, we will use a configuration file and environment variables to configure it for our target Avalanche network (see Custom Configuration for more information).

The file terraform/multipass/local-test-network.yml is templated by Terraform.

Set the ASH_CONFIG and the AVALANCHE_NETWORK environment variables to use this configuration:

export ASH_CONFIG=terraform/multipass/local-test-network.yml

Create a new wallet

Creating a wallet is actually generating a new private key. We can do it with the wallet generate command:

ash avalanche wallet generate

Store your private key in a safe place! You will need it to sign transactions.


Wallets generated with the Ash CLI only give access to one account (one address per blockchain).

Store and reuse the private key

An acceptable solution for test environments is to generate a JSON file with the wallet generate --json command:

# Generate a JSON file with the private key
ash avalanche wallet generate --json > ~/.config/ash/test-wallet.json
# Secure the file so that only you can read it
chmod 600 ~/.config/ash/test-wallet.json

You can then easily retrieve the private key with jq and leverage the AVALANCHE_PRIVATE_KEY environment variable:

export AVALANCHE_PRIVATE_KEY=$(jq -r '.cb58' ~/.config/ash/test-wallet.json)

Using the AVALANCHE_PRIVATE_KEY environment variable is the safest way to interact with wallets (as long as you keep the private key out of your shell history!).

Show information about the wallet

You can get the list of the wallet's addresses with the wallet info command:

ash avalanche wallet info
Wallet information:
Hex private key: 0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027
CB58 private key: PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
X-Chain address: X-fuji18jma8ppw3nhx5r4ap8clazz0dps7rv5u6wmu4t
P-Chain address: P-fuji18jma8ppw3nhx5r4ap8clazz0dps7rv5u6wmu4t
EVM address: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC

The addresses will be different for you as the private key is randomly generated.
Also, the X-Chain and P-Chain addresses are different depending on the network (Fuji, local, etc.)!

Fund the wallet

Now that we have a wallet and its addresses, we can transfer some AVAX to it:

  • On local Avalanche networks, we will transfer AVAX on the X-Chain from the pre-funded account (see Pre-funded account for more information).
  • On the Fuji testnet, we will use the official Fuji Faucet to request a 2-AVAX airdrop on the C-Chain.

Check the wallet balance before the transfer

Let's use the x balance command to check the wallet's balance on our local network:

ash avalanche x balance X-local1aszv6y7ugcnhgfvd7lzv8v3fk9hytlpstcazfk
Balance of 'X-local1aszv6y7ugcnhgfvd7lzv8v3fk9hytlpstcazfk' on X-Chain (asset 'AVAX'):  0

Transfer AVAX to the wallet

Let's use the x transfer command to transfer 2 AVAX to our new wallet (from the pre-funded account):

ash avalanche x transfer 2 X-local1aszv6y7ugcnhgfvd7lzv8v3fk9hytlpstcazfk \
-p PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN -w
Waiting for transaction to be accepted...
Transfered 2 of asset 'AVAX' to 'X-local1aszv6y7ugcnhgfvd7lzv8v3fk9hytlpstcazfk'!
Transaction ID: BoLhWiiwfA7b2rq7WUyNTQrZ54nRqCYVSLt6oYWKc2AX5Lmpu

We used the -w flag to wait for the transaction to be accepted.

Check the wallet balance after the transfer

ash avalanche x balance X-local1aszv6y7ugcnhgfvd7lzv8v3fk9hytlpstcazfk
Balance of 'X-local1aszv6y7ugcnhgfvd7lzv8v3fk9hytlpstcazfk' on X-Chain (asset 'AVAX'):  2

Great! We can now use this wallet to interact with blockchains on the network.

Transfer AVAX to the P-Chain

In order to perform Subnet-related operations (e.g. create Subnets/blockchains, add validators), we need to transfer some AVAX to the P-Chain. We will use Avalanche Wallet to do so.

Connect to the wallet with Avalanche Wallet

Open a new tab in your browser and open:

Forward the Avalanche HTTP API port using socat

Modern browsers don't allow to connect to other addresses than from the Avalanche Wallet. We will use socat to forward the Avalanche HTTP API port of validator01 to the host:

  1. Install socat
    # On Ubuntu
    sudo apt install socat
    # On macOS
    brew install socat
  2. Forward the port
    sudo socat TCP-LISTEN:9650,fork "TCP:$(terraform -chdir=terraform/multipass output -json validators_ips | jq -r '.[0]'):9650"
  3. Keep the terminal open and go back to the browser tab.

Add a custom network

On the top right corner, click on the 🟢 Mainnet and then Add Custom. Use the following values:

Network Name: Ash Local Network
Explorer API: N/A
Explorer Site: N/A

Then click Add Network and select it.

Access the wallet

Click on Access Wallet and select Private Key. Paste the private key of the wallet and click Access Wallet.

Transfer AVAX to the P-Chain

Follow the Avalanche Wallet FAQ to transfer AVAX to the P-Chain from the X-Chain or C-Chain.