Fuji Workflow
Learn how to use the Fuji Testnet.
Introduction
Fuji is the Avalanche network's test network. You can use it to test your dapp or smart contract after you've developed it locally. Fuji is typically on the same version as the Avalanche Mainnet, but sometimes it is running an unreleased version of AvalancheGo.
In general, you can expect Fuji's behavior to be about the same as Avalanche Mainnet. Tools such as a explorers and wallets should work with the Fuji Testnet.
In this tutorial, we'll go through an example Fuji workflow to show how it can be used. We'll do the following:
- Set up Fuji network on Core (optional)
- Generate a 24 word english mnemonic vian AvalancheJS
- Derive external C-Chain addresses vian AvalancheJS
- Get AVAX from the Fuji faucet
- Send AVAX via ethersJS
- Examine the resulting transaction on the Avalanche Explorer
- Use a private key derived from a mnemonic to sign into the Core extension (wallet)
Set up Fuji Network on Core (optional)
To access the Fuji test network, Testnet Mode needs to be enabled. In order to do that, go to Settings and click on Advanced.
Here, turn on the Testnet Mode feature. This will automatically make Core switch to Fuji Testnet.
If you are using other wallets, like MetaMask, you can add the Fuji Testnet using the following details:
- Network Name: Avalanche C-Chain
- New RPC URL:
https://api.avax-test.network/ext/bc/C/rpc
- ChainID:
43113
- Symbol: AVAX
- Explorer:
https://testnet.snowtrace.io
Generate a Mnemonic
To begin, we'll create a mnemonic phrase with AvalancheJS. Mnemonics enable us to encode strong security into a human-readable phrase. AvalancheJS supports 10 languages including English, Japanese, Spanish, Italian, French, Korean, Czech, Portuguese, Chinese Simplified and Chinese Traditional.
First, generate a 24 word english BIP39-compliant mnemonic vian AvalancheJS.
Derive Addresses
After generating a mnemonic we can use AvalancheJS to derive BIP32-compliant hierarchical deterministic (HD) Keypairs.
Generate Private Keys from a Mnemonic
As long as you have the mnemonic phrase, you can re-generate your private keys and the addresses they control.
For example, if you want to generate the private keys for the first 3 address in the C Chain keychain:
- 0x2d1d87fF3Ea2ba6E0576bCA4310fC057972F2559
- 0x25d83F090D842c1b4645c1EFA46B15093d4CaC7C
- 0xa14dFb7d8593c44a47A07298eCEA774557036ff3
you might update the example script above to the following:
Get a Drip from the Fuji Faucet
We can get a "drip" of AVAX from the Fuji faucet. If you already have an AVAX balance greater than zero on Mainnet, paste your C-Chain address there, and request test tokens. Otherwise, please request a faucet coupon on Guild.
Admins and mods on the official Discord can provide testnet AVAX if developers are unable to obtain it from the other two options. These AVAX are for the Fuji Testnet and have no monetary value.
The faucet will send some AVAX to the address and return a transaction ID (txID). This txID can be used with the Fuji Testnet Explorer to learn more about the transaction.
Check the Transaction Details
The txID, 0x1419b04559bf140ab82216f7696110936fb7d4bc1f147e3b85fef7ca1008a19e
,
can be seen on the Fuji Testnet
Explorer.
Avalanche also has a Mainnet Explorer.
Get the Balance
We can also use the Fuji Explorer to get the balance for the 1st address—0x2d1d87fF3Ea2ba6E0576bCA4310fC057972F2559.
Alternatively, we can use ethersJS to get the balance.
Sending AVAX
The faucet sent 2 AVAX to the first address we generated. Let's send AVAX from the 1st address to the 2nd address.
Verify Success
We can verify that the transaction,
0x3a5f4198b3be8d24b272f8255912aae4dcf2fb1f97f70d1787434de7b3097aac
, was
successful using the Fuji Testnet Explorer. The transaction can be seen
here.
Get the Balance
We can also use the Fuji Explorer to get the balance for the 2nd address—0x25d83F090D842c1b4645c1EFA46B15093d4CaC7C.
Alternatively, we can use ethersJS to get the balance.
Sign in to Core Extension
Lastly, we can use the mnemonic to generate a private key to access that account in Core extension. We'll see that it has the AVAX balance and that it derives the hexadecimal address from the private key.
Use the private key to access the account in Core Extension.
The balance is correct and the address is the 1st derived address.
We can repeat this login process using the private keys from the remaining 2 addresses in the script above.
Summary
The Fuji Testnet plays a critical role in testing dapps, smart contracts and financial products before deploying to the Mainnet. Tooling like AvalancheJS, the public API, faucet, and explorer helps to ensure that your testing and QA environment is close to Mainnet so that you can be confident when you launch on Mainnet.
Resources
For additional and valuable resources please see below.
Faucet
The Fuji Faucet sends AVAX to X-Chain or C-Chain addresses to help you test. (This testnet AVAX has no value.)
Wallet
Core extension and Core mobile are simple, secure, non-custodial wallets for storing Avalanche assets. They support Mainnet, Fuji and custom networks.
Explorer
The Avalanche Explorer allows you to explore the network on Mainnet and Fuji.
RPC Endpoints - Public API Server
See here.
Last updated on