“Mastering Ethereum: Building Smart Contracts and DApps” Problems and Solutions

BasBas Member Posts: 4
edited February 3 in Education
I am reading “Mastering Ethereum: Building Smart Contracts and DApps” to learn Solidity, but the code examples and commands in the book and also on github won’t work with the current version of Solidity, or for whatever reason. Therefore I would like to document the necessary changes and ask for solutions in this thread, so not every reader has to go through countless hours of googling like me.

You can find the code of the book at:

https://github.com/ethereumbook/ethereumbook

You can find the updated code at::

https://github.com/BastinJafari/Mastering-Ethereum-for-5.0/tree/master
Commands:


Here are the updated commands for Truffle:

Faucet:

FaucetDeployed.send(web3.utils.toWei("1", "ether")).then( res => { console.log( res.logs[ 0]. event, res.logs[ 0]. args) })


FaucetDeployed.withdraw( web3.utils.toWei("0.1", "ether")).then( res => { console.log( res.logs[ 0]. event, res.logs[ 0]. args) })


Caller:


When I tried to compile, I got these errors and found these solutions:

“Error: Cannot find module 'dotenv'”

Solution: npm install dotenv

Error: Cannot find module 'truffle-wallet-provider'

Solution: npm install dotenv truffle-wallet-provider ethereumjs-wallet

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined

Solution:

Create .env in project root

Put

ROPSTEN_PRIVATE_KEY="your key"
MAINNET_PRIVATE_KEY="your key"`


into it.




Post edited by Bas on

Comments

Sign In or Register to comment.