简体   繁体   English

前端更好还是后端与智能合约(erc721)集成?

[英]Is frontend better or backend for integration with smart contract (erc721)?

I have developed my ethereum smart contract and I want to integrate it with my web application.我已经开发了我的以太坊智能合约,我想将它与我的 Web 应用程序集成。 But I don't know that is integration with ReactJS a better option or integration with nodejs a better one.但我不知道与 ReactJS 集成是更好的选择还是与 nodejs 集成是更好的选择。 Please give suggestions .请提出建议。 Also I don't know how to do integration with backend through web3 library so please guide me about that.另外我不知道如何通过 web3 库与后端集成,所以请指导我。

When you are creating web3 app , most of the time you are not going to need a backend for that (Although you need a server to host your website) .当您创建web3应用程序时,大多数时候您不需要后端(尽管您需要一个服务器来托管您的网站)。 Working with and managing smart contracts are very easy at the front-end and there is no need for backend, but if your working on a large scale project , you are definitely going to need a backend for handling complex logics .在前端使用和管理智能合约非常容易,不需要后端,但如果你在做一个大型项目,你肯定需要一个后端来处理复杂的逻辑。

Next js is best option for both of that , containing node and react , also no need for manually configuring web server. Next js是两者的最佳选择,包含nodereact ,也无需手动配置 Web 服务器。

Better is next.js.更好的是 next.js。 I explained it here: https://ethereum.stackexchange.com/questions/129547/next-js-versus-react-which-to-use-when-for-your-dapp/130040#130040我在这里解释了: https ://ethereum.stackexchange.com/questions/129547/next-js-versus-react-which-to-use-when-for-your-dapp/130040#130040

Not every browser has metamask extension.不是每个浏览器都有元掩码扩展。 By using next.js, when our code is taken and rendered on the server, on the next server we can reach out to the Ethereum network and do some initial calls like data fetching, or alist of items in your smart contract.通过使用 next.js,当我们的代码在服务器上被获取并呈现时,在下一个服务器上,我们可以访问以太坊网络并进行一些初始调用,例如数据获取或智能合约中的项目列表。 we execute all of those requests on the server.我们在服务器上执行所有这些请求。 That means when next.js produces Html documents to send down to the user browser, it does not matter whether or not users are using metamask.这意味着当 next.js 生成 Html 文档以发送到用户浏览器时,用户是否使用元掩码并不重要。 It does not matter whether or not they have access to an Ethereum network.他们是否可以访问以太坊网络并不重要。 Because we already take care of the data fetching for them.因为我们已经为他们处理了数据获取。 So all the users out there who are not using metamask are going to see some information on the screen.所以所有没有使用元掩码的用户都会在屏幕上看到一些信息。

You've mentioned that you don't want to switch technologies, and while I agree with NextJS being a good platform to develop dApps on, I suggest you just use your current NodeJS server for anything that isn't web3 related and you use the web3js library from the frontend (your React) which would be very similar to a NextJS app anyway.您提到您不想切换技术,虽然我同意 NextJS 是开发 dApps 的好平台,但我建议您将当前的 NodeJS 服务器用于与 web3 无关的任何东西,并且您使用来自前端(你的 React)的 web3js 库,无论如何它与 NextJS 应用程序非常相似。

This way you don't have to switch technologies.这样您就不必切换技术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM