Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fungible Token Implementation

Objective

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.

Functionalities

  1. Total Supply: The total supply of the token should be fixed and initialized during deployment.

  2. Decimals: The token should support a specified number of decimals.

  3. Balances: Each address should have a balance associated with it, representing the number of tokens owned by that address.

  4. Transfers: Users should be able to transfer tokens to other addresses. Transfers should only be allowed if the sender has a sufficient balance.

  5. Approvals: Allowances should be implemented, allowing one address to approve another address to spend a certain amount of tokens on its behalf.

  6. Transfer on Behalf: Implement the ability to transfer tokens on behalf of another address with the approval mechanism.

  7. Events: Emit appropriate events such as Transfer and Approval for better transparency.

  8. Mint: Creates amount tokens and assigns them to account, increasing the total supply. Emits a transfer event with from set to the zero address.

UML Design

UML

Setting up Development Environment

To get started with the project, follow these steps:

1. Open a terminal/PowerShell and see if they are installed:

node -v
npm -v
git --version

2. Clone the repository:

git clone https://gitlab.mindfire.co.in/abinash.p/fungible-token.git

3. Install Hardhat and Initialization

npm install --save-dev hardhat
npx hardhat init

Deployment

  • 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

Note:

  • To run in localhost, you have to run the following commmand, in a separate terminal:
npx hardhat node

Verifying the Smart Contract

  • To verify the contract, run the following command:
npx hardhat verify --network <network name> <Deployed Address> <Args1> <Args2> ...

Note:

  • Pass the exact value of arguements in the above command as that in deploy.js.

Unit Testing

  • Run the following command:
npx hardhat test

Code Coverage

  • To generate a code coverage report, run the following command:
npx hardhat coverage

Slither Analysis

  • Install slither by running the following command:
pip3 install slither-analyzer
  • Slither require Python 3.8+.
  • To run slither, run the following command:
slither .

Contributers

Abinash Panda

GitHub: theabinashpanda

License

This project is licensed under the MIT License.

Acknowledgements

Special thanks to the contributors and reviewers who have contributed to the development and improvement of this project.

Contact

For any inquiries or assistance, please contact Abinash Panda.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages