gh0stlygh0sts.com

How to Set Up a Local Avalanche Subnet Devnet on Fuji Testnet

Setting up a local avalanche-chain/avalanche-subnet-consensus-mechanism/">Avalanche subnet devnet on Fuji testnet means configuring a private blockchain environment that runs a subnet you control, using Fuji testnet (Avalanche’s public test network) as the parent network for validation and cross-chain communication. This lets you deploy, test, and iterate on custom subnet configurations - like custom VMs, fee tokens, or validator rules - without risking real funds or affecting a production subnet on mainnet.

Prerequisites

Before starting, you will need:

Step 1: Install and Configure the Avalanche CLI

The Avalanche CLI is the primary tool for creating and managing subnets. After installation, verify it works:

avalanche --version

If the command returns a version number, proceed. Otherwise, check your installation steps.

Step 2: Create a Subnet Configuration

Use the CLI to scaffold a new subnet configuration. Run:

avalanche subnet create myTestSubnet

The CLI will walk you through choices:

The CLI generates a folder named myTestSubnet containing a subnet.json file and other configuration artifacts.

Step 3: Configure the Subnet for Fuji Testnet

By default, the CLI targets mainnet. To point your devnet at Fuji testnet, edit the subnet.json file or use the CLI flag --network=fuji when running commands. The key parameter is the Fuji testnet’s RPC endpoint (typically https://api.avax-test.network/ext/bc/C/rpc). The CLI handles this automatically if you specify the network.

If you are using a custom VM, ensure its binary is compiled and placed in the correct path. The CLI will ask for the VM binary location during creation.

Step 4: Deploy the Subnet to Fuji Testnet

Deploy your subnet configuration to the Fuji testnet:

avalanche subnet deploy myTestSubnet --network=fuji

This command:

  1. Uploads the subnet’s VM binary to a decentralized storage network (like IPFS) or makes it accessible to validators.
  2. Sends a transaction to the Fuji testnet’s Platform Chain (P-Chain) to register the subnet and its validator set.
  3. Creates the subnet’s blockchain(s).

You will need to confirm the transaction using your wallet. The CLI will prompt you to import your private key or use a hardware wallet. For testnet, using a plain private key is acceptable, but keep it secure.

After deployment, the CLI outputs the subnet’s Chain ID, RPC URL, and blockchain ID. Save these.

Step 5: Start a Local Devnet Node

To run the subnet locally, you need an AvalancheGo node that connects to Fuji testnet and validates your subnet. The CLI can automate this:

avalanche node run myTestSubnet --network=fuji

This starts a single-node devnet. The node:

If you prefer manual control, you can configure an AvalancheGo node with a custom --subnet-config file pointing to your subnet’s blockchain ID and VM binary. The CLI’s generated subnet.json includes these details.

Step 6: Connect MetaMask or Another Wallet

To interact with your subnet devnet, add its RPC to MetaMask (or Core wallet):

  1. Open MetaMask → Settings → Networks → Add Network.
  2. Enter:
  3. Network Name: e.g., “My Test Subnet”
  4. RPC URL: The one from the deployment output (usually http://127.0.0.1:9650/ext/bc/<blockchainID>/rpc).
  5. Chain ID: The one you chose (e.g., 12345).
  6. Symbol: Your token symbol (e.g., TEST).
  7. Save.

Your wallet now sees the subnet. To get test tokens, you may need to mint them using a simple script or the CLI’s faucet command (if supported). The CLI can generate a genesis.json file with initial token allocations.

Step 7: Deploy and Test Smart Contracts

With the wallet connected, deploy a test contract (e.g., a simple ERC-20 token) using Remix, Hardhat, or Foundry. Point your development tool to the subnet’s RPC. Transactions should be confirmed quickly because only your node is running.

Common Pitfalls

Testing without a local node

If you do not want to run a full node, you can deploy a subnet to Fuji testnet and use its public RPC (available from the Fuji testnet’s endpoint list in Avalanche docs). However, you lose the ability to isolate your devnet environment - other testers may affect the subnet if they join.

Next Steps

After confirming your devnet works, you can:

For production-grade testing, consider using a local testnet (e.g., a standalone Avalanche network) rather than Fuji, but the process is similar.

Not financial advice. gh0stlygh0sts.com publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.

Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.

Back to avalanche