This Truffle Box has all you need to create a DApp by following the course delivered by ChainSkills.
This box has been based from pet-shop-box.
-
Install Truffle globally.
npm install -g truffle
-
Download the box. This also takes care of installing the necessary dependencies.
truffle unbox chainskills/chainskills-box-truffle5
-
Run the development console.
truffle develop
-
Compile and migrate the smart contracts. Note inside the development console we don't preface commands with
truffle
.compile migrate
-
Run the
liteserver
development server (outside the development console) for front-end hot reloading. Smart contract changes must be manually recompiled and migrated.// Serves the front-end on http://localhost:3000 npm run dev
```javascript
truffle migrate --network ganache
truffle console --network ganache
ChainList.address //display address
accounts = await web3.eth.getAccounts() // gan account list vao accounts variable
amountAccount_1 = await web3.eth.getBalance(accounts[1])
web3.utils.fromWei(amountAccount_1, "ether")
ChainList.deployed().then(function(instance){app=instance;})
app.sellArticle("iphone7", "selling in order to buy iPhone8", web3.utils.toWei(web3.utils.toBN(3),"ether"), {from: accounts[1]})
```
truffle migrate --compile-all --reset --network ganache
var sellEvent = app.getPastEvents("LogSellArticle", {fromBlock: 0, toBlock: 'latest'}).then(result => console.log('logEvent',result))
var buyEvent = app.getPastEvents("LogBuyArticle", {_seller: accounts[1]}).then(result => console.log('logBuyEvent', result))
app.buyArticle({from: accounts[2], value: web3.utils.toWei(web3.utils.toBN(3),"ether")})
app.getArticlesForSale()
app.getNumberOfArticles()
app.articles(2)