Ethereum teaching materials HW2 for NTUEE Networking and Multimedia Lab (EE3002)
node.js, npm, ganache-cli(or ganache), truffle, Metamask(browser add-ons)
~ $ sudo apt install nodejs
~ $ sudo apt install npm
~ $ npm install -g ganache-cli
~ $ npm install -g truffle
~ $ git clone https://github.com/Vimalakirti/EthHW.git
~ $ cd EthHW/
- If your os is not Windows, please rename
truffle-config.js
totruffle.js
, or just run the following command:
~ $ bash rename.sh
- Remember to run ganache on developing.
- Step-by-step
Please describe how you get the point(s) in your report.
~ $ cd 1_Hello/
- (1%) Compile the contracts
- Modify
truffle-config.js
(ortruffle.js
) - (1%) Migrate the contracts
- Run
truffle console
- (1%) Get the message:
- Change your name, we hold Vimalakirti up as an example here,
- (1%) And get the message:
~ $ cd 2_Coin/
~ $ npm install @openzeppelin/contracts@^2.4.0
- Google "ERC20" first
- And you might need this doc: https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#erc20
- Compile the contracts
- Modify
truffle-config.js
(ortruffle.js
) - Migrate the contracts
- Write your test script(solidity or javascript)
- (4%) Test the functions below:
- totalSupply() - I've done for you
- balanceOf(account) - I've done for you
- transfer(recipient, amount) - TODO
- allowance(owner, spender) - TODO
- approve(spender, amount) - TODO
- transferFrom(sender, recipient, amount) - TODO
- You should test these functionalities comprehensively and get "passing" by running
truffle test
~ $ cd 3_TodoApp/
- Compile and migrate the contracts (remember to check
truffle-config.js
ortruffle.js
) mv build react/src/
cd react
and runnpm install
, then runnpm run start
- Open your browser and enter
localhost:3000
in the URL bar - (4%) Realize web3 functions below (
react/src/index.js
line 55~85):- addTodo
- deleteTodo
- completeTodo
- undoneTodo
- Metamask should pop up on using these functions