Solidity with React Boilerplate – 反应样板的坚固性区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Solidity with React Boilerplate – 反应样板的坚固性区块链毕设代写 是一篇很好的国外资料

Solidity with React Boilerplate

Solidity with React Boilerplate - 反应样板的坚固性 Features:

  • Compiles the contract
  • Deploys the contract to ethereum network
  • Tests the contract

File info

Directory/file Description
ethereum/compile.js Compiles the smart contract and output it to a json file for easier access later.
ethereum/web3.js An already instantiated Web3 instance that has sane checking if window is accessible. This is useful when you’re trying to develop the app in nextjs or something similar.
ethereum/deploy.js Deploys the contract to the Ethereum network. Requires compile.js to run first so it can access the compiled contract. You need to change the mnemonic to the one that is tied to your own account and your own Infura endpoint either on Rinkeby or Mainnet. Just create a ‘.env’ file and put everything there.
ethereum/contract.js Used for easier interaction with your own contract. You can rename it based on the name of your own contract.
ethereum/contracts Directory of your own smart contracts
ethereum/build Generated after you run compile.js
test/Contract.test.js A generic test file for your smart contract. Uses mocha.
src Directory of ui-related files

Scripts

Script Description
test Runs contract-build to compile the contract and then runs mocha for testing
start (Generic CRA script) Starts the frontend app
contract-build Runs ethereum/compile.js to compile to contract
react-build (Generic CRA script) Builds the react app
react-test (Generic CRA script) Runs react test
react-eject (Generic CRA script) Ejects react app

Important notes / FAQ

> Metamask isn’t showing when I’m trying to transact!

Most cases you need to add window.ethereum.enable() before trying to execute methods from your contract. So, you’ll have it like this:

...  import Contract from '../ethereum/contract';   try {      window.ethereum.enable()    // you'll add this     await contract.methods.setMessage().send({                 from: accounts[0],                 value: "A New Message! Bonjour!",             }); } 

Although, I already defined it in web3.js file. If you still encountered this issue, let me know.

> Will you keep adding more?

If possible, yes. I would like to add things like:

  • Boilerplate for calling the methods of the contract in React (’cause right now it’s just plain reactjs)
  • Handler of multiple contracts
  • Boilerplate in other frameworks like NextJS or GatsbyJS
  • Easy npx script that creates the dir

Any requests? Message me and I’ll try my best to provide it or better, create a pull request!


React样板文件的坚固性

Solidity with React Boilerplate - 反应样板的坚固性特点:

  • 编译契约
  • 将契约部署到以太坊eth网络
  • 测试契约

文件信息

Directory/file Description
编译智能合约并将其输出到json文件,以便以后更容易访问。 以太坊eth/web3.js
一个已经实例化的web3实例,它可以检查窗口是否可访问。当您尝试在nextjs或类似的东西中开发应用程序时,这很有用。以太坊eth/部署.js 将合同部署到以太坊eth网络。要求编译.js首先运行,以便它可以访问已编译的协定。您需要将助记符更改为绑定到您自己的帐户和您自己的Infura端点(在Rinkeby或Mainnet上)的助记符。只需创建一个“.env”文件并将所有内容放在那里。以太坊eth/合同.js
用于更轻松地与您自己的合同交互。您可以根据自己合同的名称重命名它。运行后生成的您自己的智能合约目录编译.js 测试/Contract.test.js合同
智能合约的通用测试文件。用摩卡咖啡。 src
用户界面相关文件目录/编译.js编制合同 (通用CRA脚本)构建react应用程序
react test (通用CRA脚本)运行react test
react eject (通用CRA脚本)弹出react应用程序
src Directory of ui-related files

脚本

Script Description
test Runs contract-build to compile the contract and then runs mocha for testing
start (Generic CRA script) Starts the frontend app
contract-build Runs ethereum/compile.js to compile to contract
react-build (Generic CRA script) Builds the react app
react-test (Generic CRA script) Runs react test
react-eject (Generic CRA script) Ejects react app

重要注意事项/常见问题解答

>当我尝试交易时,元掩码不显示!

大多数情况下需要添加window.ethereum.enable启用()在尝试执行合同中的方法之前。所以,你会得到这样的结果:

...  import Contract from '../ethereum/contract';   try {      window.ethereum.enable()    // you'll add this     await contract.methods.setMessage().send({                 from: accounts[0],                 value: "A New Message! Bonjour!",             }); } 

尽管我已经在web3.js文件中定义了它。如果你还遇到这个问题,请告诉我。

>您会继续添加更多吗?

如果可能,可以。我想添加如下内容:

  • 样板文件,以便在React中调用契约的方法(’因为现在只是普通的reactjs)
  • 多个契约的处理程序
  • 在其他框架(如NextJS或GatsbyJS)中的样板文件
  • Easy npx script that creates the dir

有任何请求吗?给我发信息,我会尽力提供,或者更好,创建一个请求!

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/21744.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Solidity with React Boilerplate – 反应样板的坚固性区块链毕设代写

提供最优质的资源集合

立即查看 了解详情