Bytom Dapp Development Notes (a): architecture design

Brief introduction

Research has been a year than the original chain, chain used than the original several dapp, and recently also made a plug-in based on their wallet dapp, we summarize some pit encountered some technical details, then I will It is divided into three chapters, from the dapp design architecture, to go deep into the source code analysis dapp introduce to you than the original chain, as well as analytical framework than dapp former official recently released.

Dapp architecture design

This is the basis of all the work, from reading the source code to use than the original chain had more than wallet after the original, we are thinking about dapp than the original chain of how to do, it should be said that the block chain applications should do, before we tried to use Ethernet Square, bitcoin, super books do dapp. First we summarize the pain points of the block chain dapp:

1) can not guarantee the authenticity of the chain before data;

2) Tps is very low;

3) high cost of access, the node itself need to build;

Dapp Infrastructure Solutions

I now summarize the two dapp based architecture than the original program chain :( if a new version or a better solution please share)

Dapp certainly can not do without complex business, it certainly will use intelligent than the original chain of contracts, the following programs are supported by intelligent contract.

First, the building block chain node

In fact, build their own nodes, and application interface node provides a direct call to complete the business content block chain wallet integration features than the original source chain, to build a more convenient, a few code can be built over, but this depending on the business is not reasonable, because this back-end integration than the original source wallet (hereinafter referred to as "pc wallet") way, the equivalent of all the account information is hosting to dapp, in fact, a centralized official purse All accounts are the property of the official pipe, so there will be the center of the problem, it will eventually be used without doubt this block chain if necessary.

Own set of users than the original chain of modules, users can use pc purse, wallet client, such as mobile wallet, your users can back up their information, the entire disclosure of all transaction information to the block chain can be found inside the browser. This program is just achieved a major transaction on the chain.

ps: Of course, but it is still at work, that all interfaces in the PC wallet to achieve a dapp, then combined business, but more than the original source code is constantly updated, but also with its version of the update, and then update their applications obviously not practical.

Talk about the inside of the pit :

1)账户BTM问题,这种方案每个dapp账户底层都要绑定一个钱包的用户,可以展现地址用户自己充值、直接在dapp里面充值、完成任务派送这些等,但是初始化账户拥有BTM需要有时间过程,正常应用这样的体验,早就让用户关闭了。

2)UTXO问题,比原链是基于utxo未花费输出交易模型,当自己的UTXO参与的交易没有确定是无法使用的,但是dapp这里绑定的用户,不能保证他有足够多的UTXO,除非自己转账的时候让他拆分,否则会类似单线程的操作,也是比较慢。

3)用户无法获取自己的私钥,在比原链PC钱包,是一套私钥,派生多个账号这样,就是说一个钱包就一套私钥,这个不能给用户。这样又违背了区块链的去中心化的问题。

总的来说,这个方案是单纯保证了dapp交易上链,但是各方面明显不足。

二、插件钱包(Byone)方案

这个方案是今年比原链推出的dapp新型的解决方案,有解决到方案一的痛点,这个也是我比较提倡的方案,现在比原链的智能合约功能已经非常强大,如果做复杂的dapp,用这个方式比较好。

简单来说就基于chrome开发了一个插件钱包,安装完插件,用户直接可以创建账户,使用账户的转账功能,里面有BTM的转账功能,账户的备份功能....是比较完整的一个钱包,这个钱包最大的作用就是包含了丰富的开发者api,可以支持开发者去实现智能合约交易。


我们重点说一下这个结构的技术原理,如图

1)Dapp前端,就是前端页面,插件钱包是基于chrome的,所以这里代表的就是新的页面集成了插件钱包(Byone)的api。

2)Byone,就是在chrome应用商店里面可以搜索到,点击安装就行,当前版本是2.0.0,非常好用。

3)Bufferserver服务器,官方提供demo里面这模块属于缓存服务器,其实这个应该改成Dapp后端,实际业务逻辑还有很多需要后端辅助,例如排行榜、非BTM比原资产交易等。(这块后面重点开一章去说清楚),现在理解称为后端就可以。

4)Blockcenter,其实就是官方提供的服务,直接提供接口可以触发比原链的交易功能,这样解决了上面的方案,避免需要自己搭建node节点,让dapp开发者更加容易接入。

总结

两套方案里面,方案一个人认为属于早期的方案,随着比原链的发展,我们可以适当了解有助于我们理解比原链的架构设计,而且在方案二里面,也一定要用到PC钱包,它可以协助我们开发者提高开发效率100倍,没有夸张,是100倍。

插件钱包现在还在推广还有完善当中,不过功能已经非常成熟了,所以Dapp开发者赶紧抓紧去使用来开发属于自己的dapp吧。

下一章我们重点说一下Dapp的开发流程。以及遇到的一些坑,还有粘贴源码。

作者:天才的饭桶

Guess you like

Origin www.cnblogs.com/bytom/p/11303181.html