Live preview: flippincoin.netlify.app
A Decentralized application build for the Ethereum Network. Part of programming course Ethereum201 on academy.ivanontech.com.
Build with Truffle and React
- Have
yarn
installed - Make sure to have Truffle installed globally via
npm install -g truffle
. It is developped on v5.1.12, so things might break in other versions. - Run a local blockchain via Ganache, or Ganache-cli
- Have MetaMask installed in the browser
git clone
cd smart-contracts
yarn install
Deploy to the local blockchain via truffle deploy
(or truffle migrate
)
Use --reset
to force a new deploy
cd client
yarn install
Start local server via yarn start
On each deploy, make sure to:
- change in
/client/constants.js
theCOINFLIP_ADDRESS
to the deployed contracts address - copy the new abi file to
/abis.js
Enable / disable, and update the suitable networks in truffle-config.js
Get mmnomonic seedphrase add it to `smart-contracts/.secret``
To deploy:
- Run
truffle deploy --network <<network>>
to migrate to<<network>>
- Replace the address in
client/constants
- Replace the abi in
client/abis/coinFlip.js
- Make sure to fund the contract
Have netlify-cli
installed
npm install netlify-cli -g
To deploy:
- Update supported networkds in
client/constants
netlify deploy
Run truffle console
to open the truffle console, followed by test
Run truffle console --network <<network>>
to open the truffle console when deployed to <<network>>
Open console (as described in Tests), then call let instance = await CoinFlip.deployed()
get an account via let accounts = await web3.eth.getAccounts()
call a fucntion like instance.flipCoin({from: accounts[0], value: web3.utils.toWei("0.0001", "ether")})
or instance.deposit({from: accounts[0], value: web3.utils.toWei("0.1", "ether")})