The objective of this project is to implement a basic fungible token adhering to the ERC20 standard without utilizing external libraries like OpenZeppelin. This token will support standard functionalities such as transferring tokens, approving and transferring on behalf of another address, and querying token balances.
-
Total Supply: The total supply of the token should be fixed and initialized during deployment.
-
Decimals: The token should support a specified number of decimals.
-
Balances: Each address should have a balance associated with it, representing the number of tokens owned by that address.
-
Transfers: Users should be able to transfer tokens to other addresses. Transfers should only be allowed if the sender has a sufficient balance.
-
Approvals: Allowances should be implemented, allowing one address to approve another address to spend a certain amount of tokens on its behalf.
-
Transfer on Behalf: Implement the ability to transfer tokens on behalf of another address with the approval mechanism.
-
Events: Emit appropriate events such as Transfer and Approval for better transparency.
-
Mint: Creates amount tokens and assigns them to account, increasing the total supply. Emits a transfer event with from set to the zero address.
To get started with the project, follow these steps:
node -v
npm -v
git --version
git clone https://gitlab.mindfire.co.in/abinash.p/fungible-token.git
npm install --save-dev hardhat
npx hardhat init
-
Create a .env file and add the necessary keys and IDs according to sample.env file.
-
Don't forget to add .env to your .gitignore.
Then, run the following command:
npx hardhat run --network <network name> scripts/deploy.js
- To run in localhost, you have to run the following commmand, in a separate terminal:
npx hardhat node
- To verify the contract, run the following command:
npx hardhat verify --network <network name> <Deployed Address> <Args1> <Args2> ...
- Pass the exact value of arguements in the above command as that in deploy.js.
- Run the following command:
npx hardhat test
- To generate a code coverage report, run the following command:
npx hardhat coverage
- Install slither by running the following command:
pip3 install slither-analyzer
- Slither require Python 3.8+.
- To run slither, run the following command:
slither .
GitHub: theabinashpanda
This project is licensed under the MIT License.
Special thanks to the contributors and reviewers who have contributed to the development and improvement of this project.
For any inquiries or assistance, please contact Abinash Panda.