# ZkSync — how to create your own ERC-20 token

By [Sr20de](https://paragraph.com/@sr20de) · 2023-03-28

---

In this guide, I will show you how to create your own ERC-20 token on the ZkSync Era testnet using [Hardhat](https://hardhat.org/) and the [OpenZeppelin](https://www.openzeppelin.com/) smart contract library.

We will have a full-fledged ERC-20 token. It can be added to Metamask and sent to other addresses like any other tokens.

All work will be done in Windows.

Wallet
------

You must have a wallet with some ETH balance on the ZkSync Era testnet.

Fund your wallet in faucet [https://goerli.portal.zksync.io/faucet](https://goerli.portal.zksync.io/faucet) or transfer ETH from the Goerli network.

Also, you must have a private key from the wallet, we will use it in the code.

Node.Js and Yarn
----------------

Download and install Node.Js from here [https://nodejs.org/en](https://nodejs.org/en)

![](https://storage.googleapis.com/papyrus_images/16ba3c1c259b39e5746fc5221a6f1a05754b2116fbd88dca54426e680c3869b1.webp)

Check that NodeJs is installed. To do this, open the Windows command prompt (in the Search menu, type cmd and select Command Prompt). At the command promt, enter:

    node -v
    

If Node Js installed normally, the version will be output:

![](https://storage.googleapis.com/papyrus_images/04c4af23ea7cb9be2645d6973a7fb9e7d0eb60cd3827dab9ad3eaadcfbbaeb36.webp)

Now install Yarn. To do this, on the command line, enter

    npm install --global yarn
    

Then to check, enter the command:

    yarn -v
    

If Yarn installed normally, the version will be output:

Begin
-----

We will take the necessary files from my repository [ZkSync contracts examples](https://github.com/Sr20dem/zksync-contracts-examples)

Download the archive with files [https://github.com/Sr20dem/zksync-contracts-examples/archive/refs/heads/main.zip](https://github.com/Sr20dem/zksync-contracts-examples/archive/refs/heads/main.zip) and unpack.

While in the `zksync-contracts-examples-main` folder, type cmd in the address bar and hit enter to open a terminal in that folder:

![](https://storage.googleapis.com/papyrus_images/f7240fe2b8a13e01ceb86a147a966835e716d61460c84e91668884b3b265ad9e.webp)

Terminal will open

![](https://storage.googleapis.com/papyrus_images/0999ca6564be585879db6c205f73e492a860bae9af1a2b30c809710142a89d63.webp)

Initialize:

    yarn init -y
    

Add the required packages:

    yarn add -D typescript ts-node @types/node ethers@^5.7.2 zksync-web3 @ethersproject/hash @ethersproject/web hardhat @matterlabs/hardhat-zksync-solc @matterlabs/hardhat-zksync-deploy
    

Add the OpenZeppelin library:

    npm install @openzeppelin/contracts
    

Do not close the terminal and proceed to edit files.

MyZkSyncToken.sol
-----------------

The contracts folder contains the `MyZkSincToken.sol` file. This is a solidity file with token parameters. Open it with any text editor and change these 3 values to whatever you need:

*   ticker MZT
    
*   name MyZkSincToken
    
*   quantity (1000000)
    

![](https://storage.googleapis.com/papyrus_images/ed4bc53897bcdcfa78b53e2a14266a086457fd2c45ea1151b64d7fe45e9d1a64.webp)

After that, save the file.

deploy.ts
---------

The deploy folder contains the `deploy.ts` file. This is a file with instructions on how Hardhat will deploy the smart contract. Open it with any text editor and change `<WALLET-PRIVATE-KEY>` to your wallet private key.

![](https://storage.googleapis.com/papyrus_images/aa70e2cc4a50267855e8730f7d18af42127ddeffe96ccf9e9d6544f6950e4eb1.webp)

After that save the file.

Compilation
-----------

Return to the terminal and type:

    yarn hardhat compile
    

This command will compile and prepare the MyZkSyncToken.sol file for deployment. The `artifacts-zk` and cache-zk folders will be created in the main folder

Deploy
------

Type in terminal:

    yarn hardhat deploy-zksync
    

The process of deploying the token to the network will begin. Deployment transaction fee will be charged. The commission is usually small, but during a heavy load on the network it can reach 0.03 ETH. If the deployment is successful, a message will appear in the terminal about the successful creation of a smart contract and its address will be displayed:

![](https://storage.googleapis.com/papyrus_images/be85dfb6152ea474f16cb579627e58d9a6d30b1ba2896e636f6594d5443000d8.webp)

You can view your token in the [explorer](https://goerli.explorer.zksync.io/) by entering the address of the generated token.

You can copy the address of the contract and paste it into Metamask:

![](https://storage.googleapis.com/papyrus_images/2865e270f6af97f85d2317158bd6070f42f75a34755c83c06b645295ad2743ee.webp)

Good luck with smart contracts!

---

*Originally published on [Sr20de](https://paragraph.com/@sr20de/zksync-how-to-create-your-own-erc-20-token)*
