This project aims to implement a token sale for an ERC20 token with specific functionalities as outlined in the assignment. The goal is to raise funds of 2 ETH by selling ERC20 tokens to investors.
- Investors can participate in the token sale by sending ETH.
- Upon purchase, tokens are immediately distributed to the respective investors.
- The token sale automatically stops once the minimum fundraising goal of 2 ETH is achieved, and further token sale is disallowed.
- Additionally, the token sale concludes after 32 blocks are produced post-contract deployment.
- After the token sale ends, there's a provision to transfer all ETH from the smart contract to a specific external address.
- This project ensures a streamlined process for fundraising through token sale while maintaining security and efficiency.
- Clone the repository by running the following commands.
git clone https://gitlab.mindfire.co.in/abinash.p/assignment-2-token-sale
-
Setup the hardhat by following link: Click here
-
Install ethers by running the following command:
npm i ethers
- Run the following command:
npx hardhat test
-
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> ...
- To install the code coverage, run the following command
npm i coverage
- To generate a code coverage report, run the following command
npx hardhat coverage
- To install slither, run the following command
pip3 install slither-analyzer
- Slither require Python 3.8+.
- To run slither, run the following command:
slither .
- ERC20Token contract is deployed at 0xfDa0E76437f94173aD8be0C313F993c2e0Db504a
- TokenSale contract is deployed at 0xd0D2d9196fD746b80014d4a60791d9Bc32276473

