PREREQUISITE:
- Solidity
- Basic Javascript
INSTALLATION
npx hardhat
create 'contracts', 'scripts' & 'test' folders inside the project folder.
-
npm install --save-dev @nomiclabs/hardhat-waffle
-
npm install --save-dev ethereum-waffle
-
npm install --save-dev chai
-
npm install --save-dev @nomiclabs/hardhat-ethers ethers
COMPILATION
- contracts/token.sol
- write code for transfer & checking balance
- cd ./contracts
- npx hardhat compile
TEST CASES USING CHAI
- Transfer amount from Owner to Addr1
- Transfer amount from Owner to Addr2
- Transfer amount from Addr1 to Addr2
- Check sender balance before sending. [sender should have sufficient balance]
- Verify the account balances after successful transfer.
Write all the above test cases in 'test' folder.
DEBUGGING
import below module to use import "hardhat/console.sol"
hardhat.config.js
- ALCHEMY_API_KEY from https://dashboard.alchemyapi.io/ [You can see the key after creating the app]
- ROPSTEN_PRIVATE_KEY from Meta Mask extension.
module.exports = {
solidity: "0.8.9",
networks: {
ropsten: {
url: `https://eth-ropsten.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts: [`${ROPSTEN_PRIVATE_KEY}`],
},
},
};
DEPLOYING TO LIVE NETWORK
npx hardhat run ./scripts/deploy.js