This repository contains a simple ERC-20 smart contract and a Hardhat deployment script to deploy the contract to the Ethereum network. The ERC-20 contract allows for the creation and management of a basic fungible token, which can be used for various purposes, including tokenizing assets, creating digital currencies, and facilitating decentralized applications.
To deploy the ERC-20 contract, you need the following software and tools:
- Node.js (version 12 or above)
- Hardhat (installed globally)
- Ganache (for local development and testing)
- Clone the repository to your local machine:
git clone https://github.com/your-username/your-erc20-project.git
cd your-erc20-project
- Install project dependencies:
npm install
- Configure Ganache:
Download and install Ganache from https://www.trufflesuite.com/ganache.
Run Ganache and set up a new workspace.
The ERC-20 smart contract is located in the contracts folder. The contract is named TokenContract.sol, and it includes the standard functions for ERC-20 tokens, such as retrieving total supply, balance of tokens for an address, transferring tokens, approving token spending, and more.
- Compile the smart contract:
npx hardhat compile
- Create a '.env' file in the project root folder and paste your account private key and infura key in the key value form which is indicated in the '.env.example' file
PVT_KEY = Paste your account private key here
INFURA_KEY = Paste your infura key here
- Deploy the ERC-20 contract to the Ethereum Mainnet or Testnet network:
npx hardhat run scripts/deploy.js --network ganache
-
The deployment script will execute, and once completed, you will see the address of the deployed contract displayed in the console.
-
Here is the link of the deployed smart contract and transactions on etherscan (on goerli network)
You can also run tests to ensure the ERC-20 contract functions as expected:
npx hardhat test
The test suite will execute, and you should see the results of the tests in the console.
This smart contract is licensed under the MIT License.