开发以太坊DAPP--水果机

原理

  • 使用 truffle 框架,solidity语言进行智能合约的开发和部署

  • 使用 web3.js 来进行页面与智能合约的交互

  • 使用 ganache-cli 作为测试链进行测试

  • 使用metamask作为钱包

机器环境

  • Win10

  • Node.js

编写智能合约

npm isntall -g ganache-cli
npm install -g solc
npm install -g truffle

truffle init

npm install --save truffle-contract
npm install --save web3

cd a dir
touch ./contracts/SlotMachine.sol

编写迁移脚本

配置truffle.js文件

启动ganache-cli测试链

  • ganache-cli

  • 记录账号信息

迁移部署合约

  • truffle migrate

启动前端

  • npm install && npm run dev

GitHub地址

效果展示

Last updated