> ## 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.

# Create and transfer an ERC-20 token

> Deploy OpenZeppelin's example ERC-20 on Tavchain Testnet, read balances, transfer tokens, and verify the source with standard Ethereum tools.

Create an example ERC-20 using OpenZeppelin's implementation, deploy it through Remix and MetaMask, then transfer tokens and check the receipt in Tavchain's explorer.

> [!NOTE]
>
> A [verified GLD reference deployment](https://docs.tavchain.safeney.com/tavchain/hardhat.md#example-deployment) is available on chain **771002**, built with the Hardhat starter. This guide uses Remix; deploy your own instance and retain its original source and compiler input for verification.

This example uses **Gold (GLD)**, the fictional game currency from [OpenZeppelin's ERC-20 guide](https://docs.openzeppelin.com/contracts/5.x/erc20). It is a valueless test token, not gold-backed, native TAV or an official Tavchain asset. Gas fees are paid in Test TAV.

## Before you begin

[Connect MetaMask](https://docs.tavchain.safeney.com/tavchain/connect.md) to Tavchain Testnet, chain ID **771002**, and obtain [Test TAV](https://docs.tavchain.safeney.com/tavchain/faucet.md). Use a second public address you control for the token transfer.

## Create the contract

In [Remix](https://remix.ethereum.org/), create `GLDToken.sol` and paste:

```solidity GLDToken.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC20} from "@openzeppelin/contracts@5.6.1/token/ERC20/ERC20.sol";

contract GLDToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("Gold", "GLD") {
        _mint(msg.sender, initialSupply);
    }
}
```

This follows OpenZeppelin's MIT-licensed example with its dependency pinned to **5.6.1**. The constructor gives the initial supply to the deploying account. No extra minting function or administrator is added.

Compile with Solidity **0.8.21+commit.d9974bed**, **Shanghai**, optimization enabled and **200 runs**. Remix resolves the versioned import; retain the source, imported files and original compiler input for verification.

## Deploy 1,000 example tokens

ERC-20 amounts are integers in the token's smallest unit. OpenZeppelin's default `decimals()` is **18**, so:

| Display amount | Raw contract amount |
| - | - |
| 1 GLD | `1000000000000000000` |
| 10 GLD | `10000000000000000000` |
| 1,000 GLD | `1000000000000000000000` |

1. In **Deploy & Run Transactions**, choose **Browser Extension → MetaMask** and confirm the network is **Custom (771002)**.
2. Select **GLDToken**.
3. Enter `1000000000000000000000` for the constructor's `initialSupply`.
4. Leave **Value** at **0**. You are creating tokens, not buying them with TAV.
5. Click **Deploy** once, review the deployment and fee in MetaMask, and confirm.
6. Wait for a successful receipt. Save the contract address and transaction hash.

Follow [deploy and interact](https://docs.tavchain.safeney.com/tavchain/deploy-token.md) for the wallet workflow. If the result is unclear, check wallet activity and the receipt before trying again.

## Read the supply and balance

Expand your deployed **GLDToken** in Remix. Read:

| Method | Expected result immediately after deployment |
| - | - |
| `name()` | `Gold` |
| `symbol()` | `GLD` |
| `decimals()` | `18` |
| `totalSupply()` | `1000000000000000000000` |
| `balanceOf(your deploying address)` | `1000000000000000000000` |

These reads do not require a wallet transaction or gas payment.

## Transfer 10 GLD

1. Expand **transfer**.
2. Enter your second account's public address in `to`.
3. Enter `10000000000000000000` in `value`.
4. Keep Remix's separate transaction **Value** at **0**.
5. Click **Transact** once. Review and confirm the interaction in MetaMask.
6. Wait for a successful receipt and check the **Transfer** event for the sender, recipient and raw amount.

If no other transfers occurred and the recipient started with zero GLD, the sender now has **990 GLD**, the recipient **10 GLD**, and total supply remains **1,000 GLD**. Gas reduces the sender's Test TAV balance separately.

## Inspect and verify

Search the deployment and transfer hashes in [the explorer](https://explorer.tavchain.safeney.com/). Check the chain, contract address, successful receipt and token-transfer event.

Follow [verify a contract](https://docs.tavchain.safeney.com/tavchain/verify-contract.md) using **Standard JSON input**, including the OpenZeppelin imports and original compiler settings. A source file with unresolved imports is not the complete verification input. Once verified, the explorer exposes the ABI's read/write methods.

To display GLD in your wallet, use its custom-token import flow on Tavchain Testnet with your deployed contract address and the token's actual symbol/decimals. Importing a token only changes its display in that wallet.

## Example token

Open the [Hardhat GLD reference contract](https://explorer.tavchain.safeney.com/address/0x9FEE6A0eAf071Dc6fFa1B6193cE1ab52E085F525?tab=contract) to inspect its verified source, deployment and transfer transactions on chain **771002**. The [Hardhat guide](https://docs.tavchain.safeney.com/tavchain/hardhat.md#example-deployment) records its 1,000-GLD initial supply and the balances after a 10-GLD transfer.

The reference was built with Hardhat's npm import path. This Remix guide uses a versioned import path, so its compiler input and metadata differ. Deploy your own instance to follow the initial-supply and transfer steps above.

Source filenames and compiler settings affect verification metadata. Keep your own original input. This demonstration is not an official Tavchain token or a security audit.

## Continue locally

[Use the Hardhat starter](https://docs.tavchain.safeney.com/tavchain/hardhat.md) for local compilation, contract tests and a disposable Ignition deployment of the same GLD example. Its local npm import path and artifact metadata differ from this Remix build.

## Related guides

* [EVM contract workflow](https://docs.tavchain.safeney.com/tavchain/contracts.md)
* [Read an ERC-20 balance](https://docs.tavchain.safeney.com/tavchain/api/reference-token.md)
* [Verify a contract](https://docs.tavchain.safeney.com/tavchain/verify-contract.md)
* [Transaction receipts](https://docs.tavchain.safeney.com/tavchain/api/transaction.md)


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