简体   繁体   English

如何将 Solidity 智能合约与移动应用程序连接起来

[英]How to connect solidity smart contract with mobile app

I am new to smart contract development.我是智能合约开发的新手。 I would like to create a mobile app that can connect to solidity, but I am not sure how.我想创建一个可以连接到solidity的移动应用程序,但我不确定如何。

There is a lot of documentation on how to connect to web applications but not on the mobile app.有很多关于如何连接到 web 应用程序的文档,但在移动应用程序上没有。 So I am guessing there must be some server-side application in the middle?所以我猜中间肯定有一些服务器端应用程序? Because it needs to connect to Metamask and the browser.因为它需要连接到 Metamask 和浏览器。

So my question is, how to properly connect smart contracts, client-mobile app and server-side app that is able to connect to Metamask, and which tools would be most appropriate?所以我的问题是,如何正确连接能够连接到 Metamask 的智能合约、客户端移动应用程序和服务器端应用程序,哪些工具最合适?

You most of the time want to directly interact with the smart contract from the mobile device after s/he has connected the app with metamask(or other wallet application) especially to create a new transaction on the blockchain.在他/她将应用程序与元掩码(或其他钱包应用程序)连接后,您大部分时间都希望直接从移动设备与智能合约进行交互,尤其是在区块链上创建新交易。 Most of the time there is only a server-side middleware for processing a lot of blockchain data for performance gain.大多数时候,只有一个服务器端中间件来处理大量区块链数据以获得性能提升。

So from the device app you would - get blockchain data + create new tx + call a smart contract that changes the state of the smart contract因此,从设备应用程序中,您将 - 获取区块链数据 + 创建新的 tx + 调用更改智能合约的 state 的智能合约

From backend you would generally only get data that requires intensive processing and/or required to cache the data on db for performance gain.从后端,您通常只会获取需要密集处理和/或需要在 db 上缓存数据以提高性能的数据。

So depending on which platform you are developing your mobile app, you would look for a web3 library to connect to the wallet and interact with deployed smart contract.因此,根据您正在开发移动应用程序的平台,您将寻找一个web3库来连接到钱包并与部署的智能合约进行交互。 Easiest would be if you use a JS-based platform (like React Native) cause web3 js is one of the matured ones among all the web3 libraries.最简单的方法是使用基于 JS 的平台(如 React Native),因为web3 js是所有web3库中成熟的之一。

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

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