Skip to content

Exploring developing with Ethereum smart contracts on a Sunday afternoon

Notifications You must be signed in to change notification settings

tebemis/ico-demo

Repository files navigation

ICO DEMO

Playing around with truffle framework and zeppelin smart-contracts library to build an Initial Coin Offering demo. Thanks to @gustavoguimaraes for his excellent blog post that started it all.

In order to run this web app successfully you'll have to run the following commands

cd ico-demo
truffle develop

In the development console, you'll also have to run the following commands

// Deploy the smart contracts (a.k.a. apply the migrations)
migrate

// Get test account 1
account1 = web3.eth.accounts[1]

// Get NVCoinCrowdsale instance (crowdsale.address will give you the address of the wallet)
NVCoinCrowdsale.deployed().then(inst => { crowdsale = inst })

// Buy your the first coin 
crowdsale.sendTransaction({ from: account1, value: web3.toWei(5, "ether")})

Then you can run the web app with:

cd ico-demo
npm start 

You shoudl see the wallet balances reflected correctly. It will look something like this:

Demo screenshot

Useful code snippets

Used these to play around and experiment

// Get token address for NVCrowdsale (i.e. address for NVCoin)
crowdsale.token().then(addr => { tokenAddress = addr } )
nvCoinInstance = NVCoin.at(tokenAddress)

// Check balance in NVCoin
nvCoinInstance.balanceOf(account1).then(balance => account1NVTokenBalance = balance.toString(10))
web3.fromWei(account1NVTokenBalance, "ether")

// Check account balance in ether
nvCoinInstance.balanceOf(account1).then(balance => balance.toString(10))

// Account balance in ether
web3.fromWei(web3.eth.getBalance(account1).toString(), "ether")

About

Exploring developing with Ethereum smart contracts on a Sunday afternoon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published