简体   繁体   English

我一直在尝试实现 DApp 浏览器,但无法理解移动应用程序如何与浏览器通信

[英]I've been trying to implement a DApp browser, but can't understand how the Mobile application is able to communicate with the browser

I'm currently learning different building blocks of blockchain and the different services, applications that currently exist.我目前正在学习区块链的不同构建块以及当前存在的不同服务、应用程序。 In a lot of wallet applications, I've seen them implement a DApp Browser, which lets their mobile app directly communicate with the DApp without the need to leave their application.在很多钱包应用程序中,我看到他们实现了一个 DApp 浏览器,它可以让他们的移动应用程序直接与 DApp 通信,而无需离开他们的应用程序。

I understand how they show DApps on their homepage, but the main doubts I have are surrounding how the application communicates with the browser.我了解他们如何在主页上显示 DApp,但我的主要疑问是围绕应用程序如何与浏览器进行通信。

I've been going through Metamask's mobile application github repository to understand the flow.我一直在通过 Metamask 的移动应用程序 github 存储库来了解流程。 They included a diagram too on how the architecture but it has been overwhelming to jump into for the most part.他们还包括一个关于架构如何的图表,但在大多数情况下跳入它是压倒性的。 Although I've got a bit of an idea of the flow, the main question of how the browser and application interacts is still not clear.虽然我对流程有了一些了解,但浏览器和应用程序如何交互的主要问题仍然不清楚。

If there's any article, or if you have an idea I'd appreciate the help.如果有任何文章,或者如果您有想法,我将不胜感激。

The Metamask documentation can be found here: https://docs.metamask.io/ Metamask 文档可以在这里找到: https://docs.metamask.io/

Frequently, a wrapper is used, such as onboard.js ( https://docs.blocknative.com/onboard ) or web3modal ( https://web3modal.com/ ), which allows for non-injected wallets to be connected.经常使用包装器,例如 onboard.js ( https://docs.blocknative.com/onboard ) 或 web3modal ( https://web3modal.com/ ),它允许连接非注入钱包。 Personally, I prefer the UI of onboard.js, but plenty of people use both.就个人而言,我更喜欢 onboard.js 的 UI,但很多人都使用这两种方式。 I highly recommend you use one of them.我强烈建议您使用其中之一。

Finally, typically one doesn't interact with the window.ethereum provider directly.最后,通常不会直接与window.ethereum提供者交互。 A library such as ethers.js ( https://docs.ethers.io/v5/ ) or web3.js ( https://web3js.readthedocs.io/en/v1.7.4/ ) makes writing DApps a lot easier.诸如 ethers.js ( https://docs.ethers.io/v5/ ) 或 web3.js ( https://web3js.readthedocs.io/en/v1.7.4/ ) 之类的库使编写 DApp 变得更加容易。 I personally prefer ethers.js as it is more strongly typed, but again, both are very commonly used.我个人更喜欢 ethers.js,因为它的类型更强,但同样,两者都非常常用。

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

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