Truffle React how to use the framework to build a complete smart contract

Truffle React how to use the framework to build a complete smart contract

Use solidity of truffle framework contract to develop intelligent, frontend react framework contract finalized intelligent front to back, the complete process from development to deployment.

1. version requirements

  • Truffle v5.0.28 (core: 5.0.28)
  • Solidity v0.5.0 (js-groove)
  • Node v8.11.2
  • Web3.js v1.0.0-beta.37

2. Project Initialization

  1. mkdir -p truffle
  2. cd truffle
  3. truffle unbox react

3. written contracts, compile, and deploy

  1. The Github truffle-react copy out files in the directory.
  2. copy ./source/App.js to "./client/src/App.js"
  3. copy ./source/truffle-config.js to ./
  4. copy ./source/Migration.sol ./source/SimpleStorage.sol to "./contracts"
  5. copy ./source/1_initial_migration.js ./source/2_deploy_contracts.js to "./migrations"
  6. truffle develop (port: 8545)
  7. compile
  8. migrate (--reset)

4. Start the project to see the effect

  1. cd client && npm start
  2. config metamask wallet to private chain on http://localhost:8545
  3. visit http://localhost:3000
  4. input number xxx in input box, then click "修改" button
  5. in wallet , click comfirm button
  6. in mainpage ,the The stored value is: xxx(you enter number above)

5. Summary

A complete coverage before and after the end of DAPP actually two, with the front and rear end similar to the traditional Internet projects.

Written contract, calling the deployment of Ethernet-based front-end development DAPP Square is actually relatively simple, with a focus on the logic of contracts, security. From this we can see Ethernet Square ecology powerful and complete, convenient complete development languages, tools, is indeed one of the most cattle project.

Guess you like

Origin blog.51cto.com/5249302/2424895