How to Add Custom Network on Avalanche Network

How to Add Custom Network on Avalanche Network
Visualization: How to Add Custom Network on Avalanche Network

Integrating Custom Avalanche Networks with MetaMask

The Avalanche ecosystem provides a robust and scalable platform for decentralized applications, offering high transaction throughput and low latency. While most users interact with the primary Avalanche C-Chain Mainnet, there are numerous scenarios requiring engagement with custom networks, such as testnets for development and testing, or specialized Avalanche Subnets. This article provides a comprehensive guide for technical users on how to manually add and configure custom Avalanche networks within a compatible Web3 wallet, specifically focusing on MetaMask due to its widespread adoption and interoperability with EVM-compatible chains.

Understanding Custom Networks on Avalanche

Before diving into the configuration steps, it’s crucial to understand why one might need to add a custom network. The primary Avalanche network consists of three built-in blockchains: the X-Chain for assets, the P-Chain for coordination, and the C-Chain for smart contracts (EVM-compatible). Most dApp interactions occur on the C-Chain.

However, developers and users often need to interact with alternative environments:

  • Testnets: Networks like Avalanche Fuji C-Chain mirror the mainnet functionality but use test AVAX, allowing developers to deploy and test applications without real economic risk.
  • Local Development Networks: Developers frequently set up local Avalanche nodes (e.g., using AvalancheGo or Anvil) to simulate the network environment for rapid prototyping and debugging. These local instances require custom RPC configurations.
  • Subnets: Avalanche’s architecture allows for the creation of custom, application-specific blockchains called Subnets. Each Subnet can define its own tokenomics, virtual machine, and validators, making them highly customizable. Interacting with a dApp deployed on a specific Subnet necessitates adding that Subnet’s RPC endpoint to your wallet.

Adding these networks to your wallet, such as MetaMask, is a fundamental step to interact with their respective dApps, deploy contracts, or manage assets on those specific chains.

Prerequisites

To successfully add a custom Avalanche network, ensure you have the following:

  • MetaMask Wallet Installed: Ensure you have the MetaMask browser extension installed and configured with at least one wallet address.
  • Basic Understanding of Blockchain Networks: Familiarity with concepts like RPC URLs, Chain IDs, and block explorers will be beneficial.
  • Network Parameters: The specific details of the custom network you wish to add. These typically include:
    • Network Name: A user-friendly name for identification.
    • New RPC URL: The address of the remote procedure call (RPC) endpoint that your wallet will use to communicate with the network.
    • Chain ID: A unique identifier for the blockchain network.
    • Currency Symbol (Optional but Recommended): The ticker symbol for the native currency of the network (e.g., AVAX for Avalanche).
    • Block Explorer URL (Optional but Recommended): The URL of the network’s block explorer, allowing you to view transactions and contract details.

Step-by-Step Guide: Adding a Custom Network to MetaMask

This guide will use the Avalanche Fuji C-Chain Testnet as an example, but the process is identical for any custom Avalanche network or Subnet, provided you have the correct network parameters.

  1. Open MetaMask: Click on the MetaMask fox icon in your browser’s extension bar to open the wallet interface.
  2. Access Network Selection: At the top of the MetaMask window, you will see the currently selected network (e.g., “Ethereum Mainnet” or “Avalanche C-Chain”). Click on this network name to open the network dropdown menu.
  3. Initiate Custom Network Addition: Scroll to the bottom of the network list and click on “Add network”.
  4. Select Manual Configuration: On the new screen, you will see options to add popular networks or manually add a network. Click on “Add a network manually”.
  5. Enter Network Details: A form will appear, prompting you to input the network’s specific parameters. For the Avalanche Fuji C-Chain Testnet, use the following details:
    • Network Name: Avalanche Fuji C-Chain
    • New RPC URL: https://api.avax-test.network/ext/bc/C/rpc
    • Chain ID: 43113
    • Currency symbol: AVAX
    • Block explorer URL: https://testnet.snowtrace.io/

    Important: Double-check that there are no extra spaces before or after the entered values, as this can cause connectivity issues.

  6. Save the Network: After accurately entering all the details, click the “Save” button.
  7. Verify Connection: MetaMask will automatically switch to the newly added “Avalanche Fuji C-Chain” network. You should now see “AVAX” as the primary currency in your wallet, and your balance will reflect any test AVAX you hold on the Fuji Testnet.

You have now successfully added a custom Avalanche network to your MetaMask wallet. You can switch between this and other networks using the network dropdown menu at any time.

Understanding Network Parameters in Detail

Each parameter plays a critical role in enabling your wallet to interact with the correct blockchain.

  • Network Name: This is purely for your convenience within MetaMask. Choose a name that helps you easily identify the network.
  • New RPC URL: This is the most crucial parameter. The RPC (Remote Procedure Call) URL is the gateway through which your wallet communicates with the blockchain node. It sends transaction requests and queries blockchain state. An incorrect or unavailable RPC URL will prevent your wallet from interacting with the network. Public RPCs are often rate-limited; for development or heavy usage, consider using a dedicated RPC provider (e.g., from Ankr, QuickNode, or building your own node).
  • Chain ID: The Chain ID is a unique numerical identifier specified in EIP-155 that prevents transaction replay attacks across different chains. For instance, Avalanche C-Chain Mainnet has a Chain ID of `43114`, and Fuji Testnet has `43113`. An incorrect Chain ID will result in transaction failures.
  • Currency Symbol: This defines the ticker for the native currency of the network. While optional, including it ensures your wallet displays the correct currency symbol (e.g., AVAX, ETH) and improves user experience.
  • Block Explorer URL: This allows MetaMask to link directly to the network’s block explorer when you view transaction details or your account on the explorer. This is highly recommended for troubleshooting and verifying on-chain activity.

Adding Avalanche Subnets

Adding an Avalanche Subnet follows the exact same process as adding the Fuji Testnet. The key difference lies in obtaining the correct RPC URL and Chain ID for the specific Subnet.

  • Subnet Documentation: Developers creating Subnets typically provide documentation that includes their Subnet’s unique RPC URL and Chain ID.
  • Core Wallet: Ava Labs’ Core wallet (available as a browser extension) offers an alternative for managing Avalanche networks, including Subnets. Core often provides a more integrated experience for adding and interacting with Avalanche-specific Subnets compared to MetaMask’s generic EVM approach. However, if a dApp specifically requires MetaMask interaction, manual addition remains necessary.

Troubleshooting Common Issues

Encountering problems during network configuration is common. Here are some solutions to frequently faced issues:

  • “Could not fetch chain ID” or “Invalid Chain ID”:
    • Double-check the Chain ID. Ensure it is a numerical value and correct for the specific network.
    • Verify the RPC URL. If the RPC endpoint is incorrect or unreachable, MetaMask cannot fetch the Chain ID information.
  • “Could not connect to the network”:
    • Incorrect RPC URL: Carefully re-enter the RPC URL, ensuring no typos or extra spaces.
    • RPC Downtime: The RPC endpoint might be temporarily down or experiencing issues. Try an alternative public RPC URL if available, or wait and try again.
    • Firewall/VPN Issues: Your local network, firewall, or VPN might be blocking access to the RPC URL. Try temporarily disabling them to test.
  • Funds Not Showing:
    • Wrong Network: Ensure you are on the correct custom network in MetaMask. Funds are specific to each chain.
    • Incorrect Token Address: If you are expecting a specific token, ensure you have imported its token contract address into MetaMask for the selected network.
    • Sync Issues: MetaMask might sometimes experience sync issues. Try closing and reopening your browser, or switching to another network and then back.
  • Transaction Failures:
    • Insufficient Funds: Ensure you have enough native currency (AVAX for C-Chain, or the Subnet’s native token) to cover transaction fees (gas).
    • Network Congestion: High network traffic can lead to transactions failing or getting stuck. Consider increasing gas fees.
    • Contract Errors: Interaction with a buggy smart contract can cause transactions to fail. Consult the dApp’s documentation or support channels.

Conclusion

Adding custom networks to MetaMask is an essential skill for anyone operating within the broader Avalanche ecosystem, from developers testing new dApps on Fuji to users interacting with specialized Subnets. By understanding the core network parameters and following these detailed steps, users can seamlessly extend their Web3 capabilities to a diverse range of Avalanche-based blockchains. This foundational knowledge empowers users to explore, develop, and participate in the full breadth of innovation that Avalanche’s modular architecture enables. Always ensure the RPC URLs and Chain IDs you use are from trusted sources to maintain the security of your assets.


Disclaimer: This content is for educational purposes only. Not financial advice.

Scroll to Top