> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tavchain.safeney.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build and deploy with Hardhat

> Build and test an OpenZeppelin ERC-20, deploy it to Tavchain Testnet with Hardhat Ignition, then verify its source without unlocking a signing key.

Use the Tavchain Hardhat starter to build and test the same fictional Gold (GLD) token used in the [Remix tutorial](https://docs.tavchain.safeney.com/tavchain/erc20-token.md). The local testing steps need no wallet, Test TAV or Tavchain node. The later public deployment steps use a dedicated signing account and Test TAV for gas.

> [!NOTE]
>
> The [verified GLD reference contract](#example-deployment) below is deployed on Tavchain Testnet, chain ID **771002**. Deploy your own instance when following this guide.

The starter uses Hardhat 3, TypeScript, viem, the Node.js test runner and Ignition. Its contract imports OpenZeppelin's ERC-20 implementation.

## Before you begin

Install a maintained, even-numbered Node.js release supported by [Hardhat](https://hardhat.org/docs/reference/nodejs-support), at least **22.13.0**. The reference environment uses **Node.js 24.22.1 on Linux x64**. These instructions have not been validated on Windows or macOS.

The first install and compiler download require internet access.

## Download the starter

Download [the source ZIP](https://github.com/safeney/Tavchain/releases/download/network-771002-1/tavchain-hardhat-starter3.zip) and its [SHA-256 checksum](https://github.com/safeney/Tavchain/releases/download/network-771002-1/SHA256SUMS). Extract the ZIP and open a terminal in the extracted `tavchain-hardhat-starter3` directory.

Archive SHA-256:

```text theme={null}
ee213a6c1aac71a633f898c5143f1d58b92c0f641a6bb5a39d1a8ee81c032049
```

The ZIP contains editable source, configuration, tests, an Ignition module and a dependency lockfile. Dependencies are installed by npm. No Tavchain node binary, wallet or private key is included. The source kit has MIT reuse permission with its included notices. A checksum detects changed bytes. To authenticate the archive, follow the network release's [verification instructions](https://github.com/safeney/Tavchain/releases/download/network-771002-1/VERIFY.md): its signed NETWORK-RELEASE.json includes this ZIP's hash. The archive remains unchanged; its README contains preparation-time and predecessor example references. Use this guide for the current 771002 workflow and deployment.

## Install and compile

```bash theme={null}
npm ci --ignore-scripts
npm run typecheck
npm run build
```

The lockfile fixes dependency versions. Both compiler profiles use **Solidity 0.8.21**, optimization enabled with **200 runs**, and **Shanghai**.

The contract creates **1,000 GLD** for the deploying account. GLD has 18 decimals and is a fictional test token. It is separate from Tavchain's native TAV.

## Run the contract tests

```bash theme={null}
npm test
```

The three tests check:

* Fixed initial supply, deployer balance and Gold/GLD metadata.
* A ten-GLD transfer, its Transfer event and resulting balances.
* Rejected overdrawing with unchanged balances and supply.

A successful test run reports **3 passing**. Tests use Hardhat's in-process development network and publicly known development accounts.

> [!WARNING]
>
> Never fund Hardhat development accounts with valuable assets. These local accounts are for disposable testing.

## Deploy on the local development chain

```bash theme={null}
npx hardhat ignition deploy ignition/modules/GLDToken.ts --network hardhatMainnet
```

Ignition reports a successful `GLDTokenModule` deployment and its local address. The in-process network ends when the command exits. Its address and state do not represent a public Tavchain deployment.

## Check the public network without signing

```bash theme={null}
npx hardhat run scripts/read-network.ts
```

The script reads the public chain ID and block height without depending on a previous contract deployment. It requires no private key and sends no transaction. Check that the chain ID is **771002**.

The network check does not read token balances. Follow [read an ERC-20 balance](https://docs.tavchain.safeney.com/tavchain/api/reference-token.md) for token reads.

## Prepare a public test account

Use a fresh account holding only valueless Test TAV. [Connect to Tavchain Testnet](https://docs.tavchain.safeney.com/tavchain/connect.md), chain ID **771002**, and obtain [Test TAV from the faucet](https://docs.tavchain.safeney.com/tavchain/faucet.md). Keep your public account address available so you can check the deployer.

Store only this dedicated account's private key through Hardhat's hidden prompt:

```bash theme={null}
npx hardhat keystore set TAVCHAIN_PRIVATE_KEY
```

Choose a keystore password and enter the account's private key when requested. Do not enter a recovery phrase, use a valuable mainnet account, paste secrets into chat or commit them to your project. Use the production keystore, without `--dev`. A compromised host or dependency can expose the key while unlocked. Do not use `keystore get`, which prints the secret.

## Deploy to Tavchain Testnet

```bash theme={null}
npx hardhat --config hardhat.public.config.ts ignition deploy ignition/modules/GLDToken.ts --network tavchain
```

Unlock the keystore privately. Check Hardhat's network and deployer, then confirm the deployment once. Native transaction value is zero; this constructor creates **1,000 GLD**. Save the successful transaction hash and contract address.

The public configuration uses the example settings: maximum fee **2 gwei per gas**, priority fee **0.125 gwei**, five confirmations and no automatic fee increases. These are client settings, not protocol limits or a total-fee guarantee. Check current fees before deploying; the settings may need review if network conditions change.

Keep Ignition's deployment journal. If the command fails or its result is unclear, inspect the journal, account nonce and receipt before rerunning. Do not use `--reset` to create a second deployment.

## Verify without unlocking the key

Replace `CONTRACT_ADDRESS` with your successful deployment's address:

```bash theme={null}
npx hardhat --config hardhat.verify.config.ts verify blockscout --network tavchain CONTRACT_ADDRESS 1000000000000000000000
```

The verification configuration connects without a local signing key. It needs no password, wallet signature, fee or Etherscan API key. It submits your original source, imports and compiler settings to the hosted Blockscout verifier and checks the result.

Open **Contract → Code** in the explorer and require **verified (exact match)**. A transaction receipt or visible bytecode alone is not source verification. This is not a security audit.

If verification reports a missing `TAVCHAIN_PRIVATE_KEY`, check that you selected `hardhat.verify.config.ts`. Do not expose a signing key in CI to solve a verification-only connection problem.

The npm import path differs from Remix's versioned import. Keep the original build and compiler input for [source verification](https://docs.tavchain.safeney.com/tavchain/verify-contract.md); do not mix artifacts from the two workflows.

## Example deployment

> [accordion] View the deployed GLD example
>
> The starter's GLD example is deployed on Tavchain Testnet, chain ID **771002**. Open its [verified source and compiler settings](https://explorer.tavchain.safeney.com/address/0x9FEE6A0eAf071Dc6fFa1B6193cE1ab52E085F525?tab=contract) to inspect the original contract and OpenZeppelin imports.
>
> | Reference | Value |
> | - | - |
> | Contract | [`0x9FEE6A0eAf071Dc6fFa1B6193cE1ab52E085F525`](https://explorer.tavchain.safeney.com/address/0x9FEE6A0eAf071Dc6fFa1B6193cE1ab52E085F525?tab=contract) |
> | Deployment | [Successful transaction](https://explorer.tavchain.safeney.com/tx/0xa62f6eedb3453475d819dbf865fce933cdcdae4e13604d37f135326f91a3b12c) |
> | Token transfer | [10-GLD transfer](https://explorer.tavchain.safeney.com/tx/0xa78e1dfc1c66accb0e24bf3d9a1027af564d04382d80a49f7979dcb4f732e7f4) |
> | Metadata | Gold (GLD), 18 decimals |
> | Initial supply | 1,000 GLD |
> | Verification | Exact match, Solidity 0.8.21, Shanghai, optimization enabled with 200 runs |
>
> At block **10833**, after the demonstrated transfer, the deploying account held **990 GLD** and the recipient held **10 GLD**. Supply remained **1,000 GLD**. Later transactions may change those balances. Deployment and transfer fees totaled **0.000671911875 Test TAV**; this observed fee is not a quote for future transactions.
>
> The transfer uses the existing token contract's `transfer` method. Follow [Create and transfer an ERC-20 token](https://docs.tavchain.safeney.com/tavchain/erc20-token.md#transfer-10-gld) to perform a transfer with your own deployed instance. The downloadable starter's Ignition module deploys the token; it does not include a separate public-transfer module.
>
> Deploy your own instance when following the guide. Its address, transaction hash and fee will differ. The source retains the kit's MIT notice and third-party notices.

## Related guides

* [EVM contract workflow](https://docs.tavchain.safeney.com/tavchain/contracts.md)
* [Create and transfer an ERC-20 token](https://docs.tavchain.safeney.com/tavchain/erc20-token.md)
* [Network settings](https://docs.tavchain.safeney.com/tavchain/connect.md)
* [Release status](https://docs.tavchain.safeney.com/tavchain/status.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.