Build
Tutorials
Testnet Setup

This introductory tutorial will guide you through the essential steps to set up your smart contract template, create and configure your account, and request tokens for testing on ZetaChain.

Start by cloning the example contracts repository:

git clone https://github.com/zeta-chain/example-contracts

Change directory to any of the examples, like hello and install dependencies:

cd examples/hello
yarn

To interact with a blockchain, you'll need an account. If you don't have an account, you can generate a new one using the following command:

npx hardhat account --save

This command creates a random EVM wallet and a Solana wallet, and displays the wallet information in the terminal, and saves the private key to a .env file, making it accessible to Hardhat.

If you don't want to save the wallet (for example, if you just need an address to send tokens to for testing purposes), you can run the command without the --save flag.

If you already have a private key or mnemonic, you can import it with the --recover flag:

npx hardhat account --save --recover

For EVM wallet, this will prompt you to enter the private key or mnemonic, derive the addresses, and save the private key into the .env file.

For Solana wallets, the process is as follows:

  1. It first attempts to automatically import the private key from the ~/.config/solana/id.json file.
  2. If this file doesn't exist or can't be read, you'll be prompted to enter the private key manually.

Finally, the private key is saved into the .env file.

The account command shows derived addresses in hexadecimal (for EVM-based chains), bech32 with zeta prefix for ZetaChain, base58 for Solana, and bech32 for Bitcoin.

To check the token balances:

npx hardhat balances

This command queries token balances for the account address derived from the private key specified in the .env.

If you need to query for balances as part of a script, you can also use a --json flag to output the balances in JSON format:

npx hardhat balances --json

If you want to query for token balances for a different account, you can use the --evm, --solana, or --bitcoin flag:

npx hardhat balances --evm EVM_ADDRESS --solana SOLANA_ADDRESS --bitcoin BITCOIN_ADDRESS

The balances command supports querying for native gas tokens, wrapped ZETA on all connected chains as well as ZetaChain, ZRC-20 tokens, SOL on Solana, and BTC on Bitcoin.

To request ZETA tokens from the faucet:

npx hardhat faucet

This command requests tokens from the faucet for the account address derived from the private key specified in the .env. To prevent abuse, the faucet will prompt you to sign in with GitHub. Once the process is complete, you will receive native ZETA tokens on ZetaChain testnet. It may take a few minutes for your request to be processed.

To send tokens to a different address, use:

npx hardhat faucet --address ADDRESS

Alternatively, you can install a standalone faucet CLI:

yarn global add @zetachain/faucet-cli

You can then use it with the following command:

zetafaucet -h

If the faucet is throwing an error, delete the access_token file from the project and try again.

In addition to ZETA tokens on ZetaChain, you might need tokens on connected blockchains like Ethereun, BNB and Bitcoin testnets.