- Please use Google Chrome for demo app as i didint tested it for other browsers
- Because of Truffle cli conflict with truffle.js for Win OS (see here trufflesuite/truffle#466) i hardcoded .cmd files in package.json to run commands successfully. Because of this this repo will work good for Win systems but not for *nix/mac.
git clone https://github.com/ValLisetsky/blockchain-play
and step intoblockchain-play
folder- Run
npm install
- Run
npm run testrpc
and leave it running - Run
npm run test
to run unit tests - Run
npm start
to start demo app (open chrome http://localhost:3000)
- One contract
contracts/Payment.sol
that:- keeps state
allowTransfer
that can be modified only by contract owner - method
pay
transfers Eth only whenallowTransfer
istrue
- keeps state
- All UI done with jQuery (for simplicity) and all frontend code located in
src/js/app.js
.- UI polling (2 secs)
http://test-blockchain.getsandbox.com/state
service and changesAllow Transfer
checkbox. - Any time when
Allow Transfer
checkbox is changed - its new value goes toPayment.allowTransfer
in blockchain. - Use can transfer 10 Ether by clicking
Transfer 10 Eth
button - Depending on
Payment.allowTransfer
state transfer will be competed or rolls back.
- UI polling (2 secs)
- This code can be improved :)
- No tests for UI - only Contract tests for now
- No Test Coverage collected
- For some reason Contract events not worked for me (
src/js/app.js:71
) so i switched to polling balances