The Smart Contract is developed in solidity, targeting EVM compatible blockchains. The contract is deployable on localhost, and was also deployed in the Rinkeby network.
Contract Rinkeby Address: 0x830125844C1B0da39521d7D634cccc5B48c777F3
Etherscan for Rinkeby:
https://rinkeby.etherscan.io/address/0x830125844C1B0da39521d7D634cccc5B48c777F3
The contract is called WillowCoinERC20 and it is an extension of the ERC20 and the Ownable templates provided by OpenZepellin. The contract implements the WillowCoins, and focuses on controllability of the application. Therefore, all access to the contract can only be performed by the Owner (deployer) address. This method focuses on the main application of the contract, which is targeted to be used in private chains in the future.
The contract implements all the basic ERC20 and Ownable function calls, and also is extended to implement composed of the following functions as well:
newWallet() : Attaches new wallet to contract and mints tokens
doesWalletExist() : Verifies if a specific wallet has already been attached to contract
mint() : Mints tokens to a wallet
deduct() : Deducts tokens from a wallet
ERC20 Implementation: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol
Ownable Implementation: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
How to run
To run the contract on localhost, you must have HardHat and all its dependencies installed in the machine. Download the GitHub repository. Navigate to the root of the project and run
npm install
npx hardhat node --network hardhat
You can use a second console window to interact with the contract by using ethers.js.
To run tests, you can open a second console window and run
npx hardhat test --network hardhat
The result should come as
**WillowCoinERC20**
✔ Should deployer be same address as owner
✔ Should deploy with initial supply as owners balance
✔ Should keep a record of signed up wallets (109ms)
✔ Should create new wallet with starting balance (59ms)
✔ Should not sign up wallet twice (48ms)
✔ Should not allow to access non signed up wallets
✔ Should allow to send to a wallet (88ms)
✔ Should not allow non-owner account to send to another account (91ms)
✔ Should allow to add up tokens (102ms)
✔ Should allow to deduct tokens from a wallet (76ms)
✔ Should not deduct less than wallet balance
✔ Should not allow non-owner account to deduct form another account (54ms)
12 passing (2s)