Skip to content

toinetoine/SzAbiTalkDappDevCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

怎么运行"深圳通"demo

先安装

  • Node.js 和 npm
  • Solidity
  • Truffle (用npm安装: npm install -g truffle
  • ganache-cli (用npm安装: npm install -g ganache-cli

运行

  1. 用终端进入code夹和运行truffle compile alt tag
  2. 开另一个终端窗口和运行ganache-cli -p 8545 -b 10 (让继续运行) alt tag
  3. 回来原来的终端窗口和运行truffle migrate --network development alt tag
  4. 运行truffle console --network development (会开truffle的终端)
  5. 在truffle的终端运行ShenzhenTong.deployed().then(function(instance) {SZT = ShenzhenTong.at(instance.address)}) alt tag

然后可用SZT变量使用合约:

var userA = web3.personal.listAccounts[1];
SZT.addMoney({from: userA, value: 100});
SZT.getBalance.call({from: userA}).then(function(r) { console.log(r.toString()); }); // 会打印: 100

加100块和检查你的深圳通余额

SZT.swipeIn("罗湖", {from: userA});
SZT.swipeOut("世界之窗", {from: userA});

在罗湖扫入,在世界之窗扫出(花10块 = feePerStation * 1 = 10 * 1)

SZT.swipeIn("机场东", {from: userA});
SZT.swipeOut("罗湖", {from: userA});

在机场东扫入,在罗湖扫出(花20块 = feePerStation * 2 = 10 * 2)

About

深圳ABI 30.05.2018聚会:Dapp智能合约开发

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published