最佳方式配置 Solidity 合同与 React 是什么?

huangapple go评论69阅读模式
英文:

what is the best way to configure solidity contract with react?

问题

我学习Solidity已经三个月了,但现在我不知道如何将您的合约与前端连接(使用React或Next)。
每个开发者都有他们自己的方式来应用它,就像我一样,我想用最好的方式,
比如使用Hardhat或Truffle。

英文:

I am learning solidity from last 3 months but now I am confused how to connect your contract with frontend (with react or next).
Every developer has their own way of applying it as i am, i want to with the best way
like with hardhat or truffle

答案1

得分: 1

关于连接到提供程序,@web3-react(文档)是我认为最常用的包。它支持各种连接器(Metamask等),你可以通过Google搜索找到一些好的示例。

然后,你需要使用"ethers"或"web3js"来发送交易等。选择你已经熟悉的那个。

英文:

Regarding connecting to the provider, @web3-react (docs) is the most used package I believe. It supports a wide variety of connectors (Metamask, ...) and you can find some good examples by googling.

Then you need either "ethers" or "web3js" to send transactions, etc. Choose whatever you're already familiar with.

答案2

得分: 1

IMO,开始编写web3的良好模板是:

前端:
  • ReactJs (CRA)
  • ethers.js:一个出色的库,让你通过ABI JSON文件、事件和交易函数与智能合约进行交互。对于初学者来说,我认为这个包是必不可少的。
  • @web3-react:由Uniswap.org的创始人编写,是一个与以太坊兼容钱包一起使用的良好库,但不一定非要使用。你也可以自行处理连接以太坊兼容钱包的问题。
智能合约:
  • Hardhat
  • Ganache
  • RPC URL,你可以通过像Infura这样的提供者获取测试网URL。

一般来说,对于web3项目,后端只是一个与区块链通信的RPC节点,所以使用ReactJs或NextJs取决于你。但对于初学者,我建议仅使用ReactJS。我建议你查看像UniswapOpenZeppelin这样的权威来源。

英文:

IMO, A good boilerplate to start coding on web3 is:

Frontend :
  • ReactJs (CRA)
  • ethers.js : A great library to let you interact with smartcontract through ABI json file, Events and Transactional functions. This package is considered a MUST USE for a beginner IMO.
  • @web3-react : Written by creator of Uniswap.org, Good library to work with ethereum compatible wallets, but not necessarily for you to use. you can handle connecting ethereum compatible wallets on your own.
SmartContract :
  • Hardhat
  • Ganache
  • RPC Urls , you may obtain testnet urls by providers like Infura and etc.

Generally speaking of a web3 project, a backend is nothing but a RPC Node who speaks to blockchain, So using ReactJs or NextJs is up to you. But for a beginner I would recommend using ReactJS only. I suggest you look into reputable sources such as Uniswap and OpenZeppelin

huangapple
  • 本文由 发表于 2023年2月16日 19:37:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471707.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定