Solidity编程语言解决了编写智能合约的不友好的问题,但是当合约编译并部署之后,对与这些接口的访问,对于一般的使用者来说,门槛有点高, 对普通用户来说也是非常不友好,为了使广大用户理解并方便快捷的访问区块链,以及区块链上的智能合约系统,开发者必须提供操作界面和结果查看界面,来简化用户访问和操作区块链的方式。因此一套完整的区块链DAPP,除了智能合约这些可以查询和改变区块链状态的代码,还需要用户操作界面以及连接用户操作与智能合约代码的接口。
The Solidity programming language solves the unfriendly problem of creating smart contracts, but when the contracts are compiled and deployed, access to these interfaces is somewhat high for general users and very unfriendly for ordinary users. In order for the user to understand and facilitate fast access to block chains, as well as to the smart contract system on the block chain, developers must provide interfaces and result viewing interfaces to simplify user access to and operation of block chains. A complete block chain DAPP, in addition to smart contracts, which can query and change block chain status, also requires user interfaces and interfaces between user operations and smart contract codes.
图1.15展示了一个DAPP的全景图,该系统架构图包含了从用户通过可视化界面发起操作到以太坊状态机发生改变的全流程。首先用户通过Web界面或者手机APP,将操作数据发送到一个传统的业务服务器,该业务服务器是传统互联网中心化的服务器,但是与传统系统不同的是,该系统没有像传统互联网设计那样将数据放入中心化的数据库存储,而是通过一个Web 3.0接口,将数据传送到了以太坊区公链。
Figure 1.15 shows a DAP panorama that contains a full flow from user-initiated operations through visualization interfaces to changes in the Ether-state machine. First, the user sends the operating data to a traditional business server that is central to the traditional Internet, but, unlike the traditional system, the system does not store the data in a centralized database like the traditional Internet design, but uses a Web 3.0 interface that transmits the data to the community public chain.
图1.15 DAPP架构图
& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; figure 1.15 DAPP architecture
该接口是一个JSON RPC协议,该协议有很多代码实现。目前最流行的是运行在Web容器中的Web3.js模块。Solidity编程语言经过编译之后,除了交易需要的合约初始化代码之外,还有ABI接口等描述文件,Web3.js通过这些描述文件,可以构建与以太坊智能合约虚拟机进行通讯的模块,通过JS(全称JavaScript,下文都简称JS)代码将用户的操作数据传入以太坊公链上的合约地址,智能合约虚拟机会根据函数签名和加载的函数参数,在虚拟机内执行编译成EVM Code的智能合约。在第6章的DAPP案例讲解中,会对Web3.js的设计有详细的讲解。
The interface is a JSON RPC protocol, which has many codes. The most popular is the Web3.js module, which operates in the Web container. Following the compilation of the language of the Solidity programming, and in addition to the contract initialization code required for the transaction, there are other descriptive documents such as the ABI interface, through which Web3.js can construct modules for communicating with the Etherm Smart Contract Virtual Machine, which transmits the user's operational data to the contract address in the community chain via the JS (all referred to as JavaScript, hereinafter referred to as JS) code, the smart contract virtual opportunity to execute a smart contract for translation into EVM Code within the virtual machine, based on the function signing and loading of the function parameters.
如果涉及到区块链数据的读取,则虚拟机会读取区块链上的区块数据,如果虚拟机的指令代码会修改以太坊公链的状态,那么通过调用相关的状态机指令,并消耗一定的GAS之后,就可以将修改操作提交到以太坊区块链公链网络中,这些操作往往是以交易的方式体现。
If the block chain data are to be read, the virtual opportunity to read block data on the block chain, and if the virtual machine's command code changes to the status of the community chain, the changes can be submitted to a network of public chains using the community chain, often on a transaction basis, by calling the relevant state order and consuming a certain GAS.
当虚拟机执行结束,其对区块链状态的修改会被矿工打包,当状态修改被全网共识,那么虚拟机对公链网络的状态修改也相应成功,通过查询相关的执行结果,将执行状态返回给用户交互系统,这样终端用户就可以通过交互系统,查看DAPP操作的执行结果。
When the virtual machine is finished, changes to the block chain state are packaged by the miners, and changes to the state are agreed on the whole web, the virtual machine changes the public chain network status accordingly, returning the execution status to the user interactive system by querying the relevant implementation results so that end-users can view the results of the DAPP operation through the interactive system.
2020区块链各种应用都上马了,跟我一起学《区块链DAPP开发入门、代码实现、场景应用》吧。
strong>2020 block chain applications are on the horse.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论