从架构角度深入解析 Web 3.0 与 Web 2.0 应用区别

资讯 2024-07-11 阅读:20 评论:0
大家对于区块链、智能合约、IPFS、钱包、节点等这些名词都不陌生,也大概明白他们都是做什么的,然而他们是如何联动起来服务于 Web3.0 去中心化应用的搭建的呢ÿ...
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

大家对于区块链、智能合约、IPFS、钱包、节点等这些名词都不陌生,也大概明白他们都是做什么的,然而他们是如何联动起来服务于 Web3.0 去中心化应用的搭建的呢?

You're familiar with the terms block chains, smart contracts, IPFS, wallets, nodes, etc.; you probably know what they do; #xff0c; but how they connect to the web3.0 to serve the built-up applications of the centralization of #xff1f;

  展现在我们眼前的仅仅是应用的前端,我们很难窥探到应用背后究竟是如何实现的。应用架构中的每一个组件都决定着应用的底层属性,若想真的理解 Web2.0 与 Web3.0 应用之间的本质差异,我们需要从应用的架构入手。

What we see here is only the front end of the application & #xff0c; it's hard to see how it's done. Each component in the application structure determines the underlying properties of the application & #xff0c; if you really want to understand the fundamental differences between the Web 2.0 and the Web3.0 applications & #xff0c; we need to start with the architecture of the application.

  本文作者 Preethi Kasireddy 曾在 2013 至 2015 年担任 a16z 合伙人,随后在 2016 年入职 Coinbase 担任软件工程师并在同期以智能合约工程师身份活跃在以太坊网络中。本文从应用框架维度对 Web3.0 应用进行了深度解析。律动 BlockBeats 对全文进行了翻译:

The author of this paper, Preethi Kasireddy, was a 16z partner & #xff0c from 2013 to 2015; then joined as a software engineer at Coinbase in 2016 and was active as an intelligent contract engineer in the Taiyo network during the same period. This paper provides an in-depth interpretation of the Web3.0 application from the application frame dimension. BlockBeats translated the full text & #xff1a;

Web 3.0 的应用架构

Web 3.0 application architecture

  Web 3.0 应用程序(或 DApps)的架构与 Web 2.0 应用程序完全不同。

Web 3.0 Application & #xff08; or DApps & #xff09; is completely different in structure from the Web 2.0 application.

  以 Medium,一个简单的博客网站为例子。Medium 允许用户发布自己的内容并与其他人的内容进行交互。

Take Medium, a simple blog site for example. Medium allows users to post their content and interact with that of others.

Medium 是一个 Web 2.0 应用程序,架构听起来很简单。但实际上在 Medium 的架构中,需要大量工作使这一切成为可能。

Medium is a Web 2.0 application & #xff0c; architecture sounds simple. But in Medium's structure & #xff0c; it takes a lot of work to make this possible.

  首先,Medium 需要一个地方来存储像用户,帖子,标签,评论,赞之类的基础数据。这些工作需要不断地更新数据库。

First xff0c; Medium needs a place to store basic data such as the user xff0c; post xff0c; tag xff0c; comment xff0c; c; ;. These tasks require continuous updating of the database.

  其次,像 Node.js, Java, or Python 后端代码语言决定了 Medium 的商业逻辑。例如,当新用户注册、发布新博客或在他人博客上发表评论时会发生什么情况?

Second & #xff0c; like Node.js, Java, or Python backend code language determines the business logic of Medium. For example & #xff0c; what happens when new users register, publish new blogs or comment on other people's blogs & #xff1f;

  还有,像 JavaScript, HTML, and CSS 之类的前端代码语言决定了 Medium 的 UI 逻辑。例如,网站是什么样子的,当用户与页面上的每个元素交互时会发生什么?

xff0c; front-end code language like JavaScript, HTML, and CSS determines the UI logic of Medium. For example, xff0c; what the website looks like xff0c; what happens when the user interacts with each element on the page xff1f;

  当你在 Medium 上写博客时,这些所有的东西会整合起来联动。你与它的前端互动,前端和后端交互,后端再与它的数据库交互。所有这些代码都托管在中心化服务器上,并通过互联网浏览器发送给用户。这是对当今大多数 Web 2.0 应用程序的工作原理的一个高度总结。

When you write a blog on Media, xff0c; all these things are integrated. You interact with its front end xff0c; front and back end interactive xff0c; backend interact with its database. All these codes are hosted on a centralised server xff0c; and sent to users via an Internet browser. This is a high-level summary of the working principles of most web 2.0 applications today.

现在这些全变了。

Now all this has changed.

  区块链技术为 Web 3.0 应用开启了令人兴奋的新方向。在本文中,我们将重点讨论以太坊带来的改变。

Block chain technology has opened up exciting new directions for Web 3.0 applications. In this paper & #xff0c; we will focus on changes brought about by the Taiku.

  是什么让 Web 3.0 如此不同?

What makes Web 3.0 so different #xff1f;

  与 Medium 这类 Web2.0 程序不同是,Web3.0 去除了中间层。这中间没有存储应用程序状态的中心化数据库,也没有中心化网站服务器用于存储后端逻辑。

Unlike such Web 2.0 programs as Medium, xff0c; Web3.0 removes the middle layer. There is no centralized database for the application status xff0c; there is no centralized web server for storing backend logic.

  你可以利用区块链构建程序在去中心化的状态机构建应用程序,这一系统是由互联网上的匿名节点在维护。

You can use the block chain builder for decentralised institutional construction applications xff0c; this system is maintained by anonymous nodes on the Internet.

  状态机是指一种可维持程序状态并允许新的状态写入的「机器」。区块链就是一种虚拟机,其以创世状态作为示例,随后状态根据具体规则进行转换。

A state machine is a " machine" that maintains the state of the program and allows the new state to be written. A block chain is a virtual machine & #xff0c; it uses the state of creation as an example & #xff0c; the subsequent state is converted according to specific rules.

  更重要的是,没有单一实体控制这个去中心化的状态机,它由网络中的每个人共同维护。

More importantly, xff0c; no single entity controls this decentralised state machine xff0c; it is maintained by everyone in the network.

  在 Web 3.0 中,你可以编写智能合约来定义应用程序的逻辑并将它们部署到去中心化的状态机上。这意味着每个想要构建区块链应用程序的人都在这个共享状态机上部署他们的代码。这与 Medium 的后端十分不同。

In Web 3.0 & #xff0c; you can write an intelligent contract to define the logic of the application and deploy it to a decentralised state machine. This means that every person who wants to build a block chain application deploys their code on this shared state machine. This is very different from the end of Medium.

  Web3.0 的前端和 Web2.0 的前端基本相同,有一些特例我们将在后文中讲解。

The front end of Web3.0 and the front end of Web 2.0 are basically the same xff0c; there are some special cases that we will explain later.

  下图是 Web3.0 的架构

Here's the structure of Web3.0.

深度解析

Depth Parsing

  那么,让我们更深入地了解是什么让这一切成为可能

So #xff0c; let's get a deeper look at what makes all this possible.

区块链

Block Chain

  以太坊是全球都可以参与维护的,点对点具有确定性的状态机,这让以太坊经常被吹捧为「世界电脑」。状态机上的状态更改由网络中的遵循共识规则的节点控制。

Ether is a global #xff0c that can be maintained; the dot-to-point state machine #xff0c; this allows the Ether to be often boasted as a "world computer." The state changes on the status machine are controlled by the nodes of the network that follow consensus rules.

  换句话说,它实际上被设计为世界上任何人都可以访问和写入的状态机。因此,这台机器不属于任何单一实体,而是由网络中的每个人共同拥有。

In other words, xff0c; it is actually designed to be a state machine that anyone in the world can access and write. So xff0c; this machine does not belong to any single entity xff0c; it is owned by everyone in the network.

  还有一件事要知道:数据只能写入以太坊区块链,你永远无法更新现有数据。

There is one more thing to know: #xff1a; data can only be written in the Etherkom block chain #xff0c; you will never be able to update the available data.

智能合约

Smart Contract

  智能合约是运行在以太坊区块链上的程序,用于定义区块链上发生的状态变化背后的逻辑。智能合约通常都用 Solidity 或者 Vyper 这类的高级语言编写。

Smart contracts are programs that run the Ether block chain & #xff0c; the logic behind defining the state changes that occur on the block chain. Smart contracts are usually written in advanced languages such as Solidity or Vyper.

由于智能合约代码存储在以太坊区块链上,任何人都可以检查网络上所有智能合约的应用逻辑。

Since the smart contract code is stored on the Etherkom block chain & #xff0c; anyone can check the application logic of all smart contracts on the network.

以太坊虚拟机(EVM)

Etheria virtual machine & #xff08; EVM& #xff09;

  虚拟机是用来执行智能合约中定义的逻辑并处理状态机上发生的状态变化。

Virtual machines are used to carry out the logic defined in an intelligent contract and to process state changes occurring on a state machine.

  以太坊虚拟机不理解像 Solidity 或 Vyper 的这种高阶语言。你需要将这些高阶语言编译成以太坊虚拟机可以执行的字节码。

You do not understand a high-level language like Solidity or Vyper. You need to compile these high-level languages into bytes that can be executed by the Taiyu virtual machine.

前端

Frontend

  正如我们之前提到的,前端定义了 UI 逻辑,但前端也与智能合约中定义的应用程序逻辑进行交互。

As we mentioned earlier xff0c; frontend defines UI logic xff0c; but frontend also interacts with application logic as defined in an intelligent contract.

  前端和智能合约之间的交互比上图中显示的要复杂一些。接下来让我们详细说明一下这部分。

The interaction between the front end and the smart contract is more complicated than what is shown in the figure above. Let's go over this part in more detail.

以太坊上前端代码如何与智能合约进行交互

How the front-end code in Ether is interacting with the smart contract

  我们想让前端和智能合约交互时能够触发程序的特定功能,但不要忘记,以太坊是一个去中心化的网络。所有每一个以太坊的节点都需要保存一份以太坊状态机上所有状态的副本。这个副本包括所有与智能合约相关的代码和数据。

We want to allow the front-end and smart contracts to interact with the specific function of the program xff0c; but don't forget xff0c; Etheria is a decentralised network. Every node in the ether needs to keep a copy of all states on the ether. This copy includes all codes and data related to the smart contracts.

  当我们想和区块链上的数据和代码进行交互的时候,我们要和区块链中的某一节点进行通信。因为任何节点都可以广播在以太坊虚拟机上进行交易的请求。在这之后矿工将执行交易并将结果状态更改广播到网络的其他节点上。

When we want to interact with the data and codes on the block chain xff0c; we want to communicate with one of the nodes in the block chain. Because any node can broadcast a request for a transaction on an Ether virtual machine. After that, the miners will execute the transaction and change the status of the results to other nodes on the network.

有两种方式广播新的交易:

There are two ways to broadcast new transactions xff1a;

  自己设立一个运行以太坊程序的节点

Set up a node to run the Ether program.

  使用 Infura 或者 Alchemy 第三方提供的节点

Use nodes supplied by Infoura or Alchemy third party

  使用第三方节点,能让你免去自己运行全节点所带来的麻烦。因为有大量数据需要同步的关系,设立一个以太坊的节点通常需要好几天的时间。并且同步所需的带宽和存储容量超过了一般笔记本电脑的处理能力,所以你同时需要一台性能强劲的设备。

Using third-party node & #xff0c; saving you from the trouble of running the entire node. Because there is a lot of data that requires synchronizing relationships & #xff0c; it usually takes days to set up a node in the Tails. And the bandwidth and storage capacity required for synchronisation exceeds the processing capacity of a normal laptop & #xff0c; so you need a robust device at the same time.

  此外,存储完整以太坊区块链的成本随着 DApp 的扩容而增加,你需要添加更多节点来扩张你的基础设施。当你的基础设施变得复杂到一定程度后,你将需要一个全职 DevOps 工程师(可编程运维工程师)。他们将帮助你维护基础设施,以确保你的基础设施有着可靠的正常运行时间和快速的响应时间。

In addition, xff0c; storage of integrity increases xff0c with the extension of the Dapp block chain; you need to add more nodes to expand your infrastructure. When your infrastructure becomes more complex to a certain degree xff0c; you will need a full-time DevOps Engineer xff08; programable transport engineer xff09; they will help you maintain infrastructure xff0c; and ensure that your infrastructure has a reliable normal running time and a rapid response time.

  综上所述,为了避免这些麻烦,许多 DApp 选择使用 Infura 或 Alchemy 之类的服务商来管理他们的节点。但凡事有利有弊,这也造成了一个中心化的阻塞点。但我们先不谈这个问题。

In summary, xff0c; in order to avoid these troubles xff0c; many Dapps choose to use service providers like Infoura or Alchemy to manage their nodes. But there are advantages and disadvantages xff0c; this also creates a central barrier. But let's not talk about it.

  不管是你自己设置还是使用来自第三方服务的节点,这些节点通常被称为「提供商」(Providers)。我们接下来好好说说这些「提供商」。

Whether you set up or use nodes from third-party services & #xff0c; these nodes are commonly referred to as "providers" & #xff08; Providers & #xff09; let's talk about these "providers."

每个以太坊客户端(提供者)实行 JSON-RPC 规范。这确保了前端应用程序想要与区块链交互时有一组统一的方法。JSON-RPC 是一种无状态、轻量级的远程应用程式调用 (RPC) 协议,它定义了多个数据结构及其处理规则。因为它具有传输不可知性(transport-agnostic),因此这些概念可在同一进程中被使用、穿梭在 Sockets、 HTTP 或许多不同的消息传递环境中。它使用 JSON (RFC 4627) 作为数据格式。

Each user & #xff08; Provider & #xff09; Apply JSON-RPC norms. This ensures a consistent approach when front-end applications want to interact with block chains. JSON-RPC is an improvised, lightweight remote application call (RPC) protocol & #xff0c; it defines multiple data structures and rules for their processing. It uses JSON (RFC 4627) as a data format.

  当你通过提供商连接到区块链后,你就可以读取存储在区块链上的状态。但是,如果你想写入状态,你需要在将交易提交到区块链之前,使用你的私钥对交易进行「签名」。

When you connect to the block chain through the provider, xff0c; you can read the state stored on the block chain. But xff0c; if you want to write status xff0c; you need to xff0c before you submit the transaction to the block chain; you need to " sign" the transaction using your private key.

  举个例子,假设我们运行了一个 DApp,它可以让用户阅读或发布博客文章到区块链。你在前端设置了一个按钮,允许任何人查询特定用户撰写的博客文章。但要记得,阅读区块链中的文章并不需要用户对交易进行签名。

Take, for example, xff0c; assume that we run a Dapp, it allows users to read or publish blog articles to the block chain. You set a button xff0c at the front end; allow anyone to look for blog articles written by a particular user. Remember xff0c; reading articles in the block chain does not require the user to sign the transaction.

  但是,当用户想要在区块链上发布新的文章时,DApp 会要求用户使用他们的私钥「签署」交易,只有这样 DApp 才会将交易传播到区块链上。否则节点不会接受这笔交易。

But xff0c; when users want to post new articles on the block chain xff0c; DApp will require users to "sign" their private key xff0c; only then will DApp disseminate the transaction to the block chain. Otherwise nodes will not accept the transaction.

  签署交易这个环节通常是需要使用 Metamask(小狐狸)的时候。

The signature of the transaction usually involves the use of Metamask( the fox #xff09;

Metamask 是一种工具,可让应用程序轻松处理密钥管理和交易签名。它原理非常简单,Metamask 将用户的私钥存储在浏览器中,每当前端需要用户签署交易时,它都会调用 Metamask。

Metamask is a tool & #xff0c; allows the application to easily handle key management and transaction signatures. It is very simple & #xff0c; Metamask stores the user's private key in the browser & #xff0c; & #xff0c when the user is required to sign the transaction at each current end; it calls Metamask.

  Metamask 也会作为提供商与区块链进行链接。因为 Metamask 需要签署交易,所以它与 Infura 提供的节点建立了连接。在某种程度上说,Metamask 既是提供者又是签名者。

Metamask will also be linked to the block chain as a provider. Because Metamask needs to sign a transaction & #xff0c; it has been connected to the nodes provided by Infoura. To some extent & #xff0c; Metamask is both a provider and a signatory.

在区块链上存储

Store on block chains

  当然,如果你所搭建的应用中所有智能合约和数据都存储在以太坊上的话,那么这种架构还算合理。然而,在以太坊上搭建过应用程序的人都知道,在区块链上存储虽然快捷,但价格也不菲。

Of course xff0c; if all the smart contracts and data in the applications you have built are stored on Ether, xff0c; then the structure is reasonable. But xff0c; everyone who has built the application on Ether knows xff0c; storage on the block chain is quick xff0c; but it's not cheap.

  我们要明白,用户每次在以太坊上添加新数据都要付费。这是因为去中心化的状态机是由节点来维护的,而在状态机上每新增一个状态,都会增加节点的成本。

We need to understand that xff0c; users pay for every time they add new data to Ether. This is because decentralised state machines are nodes to maintain xff0c; each new state xff0c on a state machine increases the cost of nodes.

  如果你的 DApp 每次在用户交易需要添加新状态时,都要求他们支付额外费用的话,那么用户体验是很差的。不过,使用去中心化链下存储方案,如 IPFS 或 Swarm,便可以解决这一问题。

xff0c; xff0c; xff0c; xff0c; xff0c; but xff0c; using decentralised storage programs xff0c; e.g. IPFS or Swarm, this can be solved.

  IPFS 是一个用于存储与访问数据的分布式文件系统。也就是说,IPFS 系统并不是将数据存储在一个中心化的数据库中,而是将数据分布式存储在 P2P 网络中,让你随时可以对数据进行检索。

IPFS is a distributed file system for storing and accessing data. That is, the & #xff0c; the IPFS system does not store data in a centralized database & #xff0c; it stores data distribution in the P2P network & #xff0c; it allows you to search data at any time.

「Filecoin」是 IPFS 的激励层,其作用是激励世界各地的节点来存储和检索这些数据。你可以使用像 Infura 或 Pinata 这样的提供商,因为 Infura 可以为你提供 IPFS 节点,而 Pinata 则可以让你将文件在 IPFS 中「定位」,继而得到 IPFS 的哈希值并将其存储在区块链上,且整个操作过程相当简单。

"Filecoin" is an incentive layer for IPFS & #xff0c; its effect is to motivate nodes around the world to store and retrieve these data. You can use a provider like Infra or Pinata & #xff0c; because Infoura can provide you with an IPFS node & #xff0c; and Pinata can allow you to "position" files in IPFS & #xff0c; then get IPFS Hashi values and store them on block chains #xff0c; and the whole operation is quite simple.

  Swarm 是一个去中心化的存储网络,和 IPFS 有很多相似之处,但二者也有一个明显区别。那就是,Filecoin 系统相对独立,Swarm 的激励系统是内置的,由以太坊上的智能合约来执行,用于数据的存储与检索。

Swarm is a decentralised storage network & #xff0c; and IPFS have many similarities & #xff0c; but there is also a clear difference between the two. & #xff0c; the Filecoin system is relatively independent & #xff0c; the Swamm incentive system is built & #xff0c; executed by an intelligent contract in the Tai family & #xff0c; used for data storage and retrieval.

  所以现在,有了 IPFS 或 Swarm,我们的应用架构会是这样的:

So now #xff0c; with IPFS or Swarm, our application architecture would be #xff1a;

  在下图当中,机智的你可能会注意到,前端代码并没有存储在区块链上。其实我们完全可以和我们在 Web 2.0 中所做的一样,将代码存储在 AWS 上面,但这样做也意味着你的 DApp 会受到来自中心化的制约。比方说,如果 AWS 瘫痪了怎么办?如果它对你的应用程序进行审查又该怎么办?

In the figure below, xff0c; resourceful you may notice that xff0c; front-end code is not stored in the block chain. In fact, we can just as much as we did in Web 2.0 xff0c; store code on AWS xff0c; but doing so also means that your Dapp will be constrained by centralization. For example, xff0c; what if AWS is paralysed xff1f; what if it reviews your application xff1f;

  这也就是为什么,如果你想搭建一个真正的去中心化应用程序,你会选择像 IPFS 或 Swarm 这样的去中心化存储方案来储存前端了。

That's why xff0c; if you want to build a real decentralised application xff0c; you'll choose a decentralised storage program like IPFS or Swarm to store the front end.

  所以现在你的应用架构会变成这样:

So now your application architecture will become this #xff1a;

在区块链上进行查询

Query on the block chain

  到目前为止,我们已经探讨了如何通过签署交易并将它们发送到区块链上来完成交易的写入。但从区块链上的智能合约中读取数据又该如何操作呢?主要有以下两种方式:

So far, xff0c; we've explored how to write a transaction by signing it and sending it to the block chain. But how to get data from a smart contract on the block chain xff1f; there are two main ways xff1a;

智能合约事件

Smart Contract Event

  你可以利用 Web3.js 库来查询和监听智能合约事件。你也可以使用 Web3.js 监听特定事件,并指定一个回调函数在每次事件触发时进行调用。比如说,现在假设有一个智能合约可以在每个区块中的发送者与接收者之间发送连续支付流,那么每次向接收者支付款项时,你都可以发出一个智能合约事件。前端代码可以监听由智能合约所触发的事件,并据此采取相应行动。

You can use the Web3.js library to query and listen to intelligent contract events. You can also use Web3.js to listen to specific events & #xff0c; and specify a callback function to be called when each event triggers. For example, xff0c; now assume that there is a smart contract to send a continuous payment stream xff0c between the sender and the recipient in each block; then every payment to the recipient xff0c; you can send a smart contract event. The front code can listen to an event triggered by a smart contract xff0c; and act accordingly.

The Graph

  上述方法的确可行,但它同时也有一定的不足。比如说,你可能在智能合约部署完成后才发现,自己要发送的事件并没有包含在合约当中,这该如何是好?不幸的是,你只能重新部署一个新的智能合约,并将该事件与相关数据放入新的合约当中。不仅如此,回调函数也很难处理不同的 UI 逻辑。

The above approach does work xff0c; it also has some shortcomings. For example, xff0c; you may find xff0c after the deployment of the smart contract has been completed; the events you are about to send are not included in the contract xff0c; this is how xff1f; xff0c, unfortunately; you can only redeploy a new smart contract xff0c; and put the event and related data in the new contract. Not only this xff0c; and it is difficult for the echo function to handle a different UI logic.

  这时就该让「The Graph」上场了。

It's time for "The Graph" to play.

  The Graph 是一个链下数据索引方案,可以方便人们在以太坊上查询数据。在 The Graph 中,你既可以定义哪些智能合约需要索引、哪些事件与函数调用需要监听,也可以规定如何将传入的事件转化为前端逻辑(或任何正使用 API 的程序)可处理的实体。它使用 GraphQL 作为查询语言,这种语言深受前端工程师的喜爱,因为与传统的 REST API 相比,它能传达更多信息。

The Graph is a chain-based data indexing program & #xff0c; it facilitates access to data in Etheria. In The Graph & #xff0c; you can either define which smart contracts require indexing, which events and functions call for listening xff0c; you can also specify how to convert incoming events into forward logic xff08; or any API program xff09; processable entities. It uses GraphQL as a query language xff0c; this language is very popular with front-end engineers xff0c; it can convey more information than the traditional REST API xff0c; it can.

  通过索引区块链数据,The Graph 可以让我们在应用逻辑中查询链上数据,并且几乎不会出现延迟的情况。

The index block chain data xff0c; The Graph allows us to search the chain for data xff0c in the application logic; and there are few delays.

 现在,你的 DApp 架构大概是这样:

Now #xff0c; your Dapp structure is probably like this #xff1a;

现在只剩下最后一个重要问题:扩容。

There is only one last important issue left: #xff1a; magnification.

DApp 的扩容

Extension of DApp

  你可能已经听说了,以太坊不具备可扩展性,至少目前还没有。

You may have heard of #xff0c; Etheria does not have scalability #xff0c; at least not yet.

以太坊 Gas 平均价格

Etheria Gas average price

平均交易费用

Average transaction costs

平均区块规模

Average block size

  显然,问题在于,以太坊上 Gas 费用高昂且区块几近饱和,在它上面搭建 DApp 会给用户带来非常不好的体验。不过值得庆幸的是,一些相关方案正在开发当中。

Obviously xff0c; the problem is xff0c; xff0c; xff0c)

  Polygon 便是一个很受欢迎的 Layer 2 扩容方案。在 Polygon 中,交易的处理与执行是由「侧链」而非主链来完成的。这些侧链是与主链相连的二级区块链。每隔一段时间,侧链就会将其最近的区块聚合起来提交给主链。

Polygon is a popular Layer 2 expansion programme. In Polygon & #xff0c; the processing and execution of transactions is done by the "side chain" rather than by the main chain. These side chains are secondary blocks linked to the main chain. xff0c every once in a while; the side chain brings together its nearest blocks to the main chain.

  同样,Optimistic Rollup 和 zkRollup 也属于 Layer 2 方案,工作原理也都类似:他们用「Rollup」智能合约在链下将大量交易进行捆绑,然后定期将这些交易提交给主链。

Similarly, xff0c; Optimistic Rollup and zkRollup are also part of the Layer 2 program & #xff0c; their working principles are similar to xff1a; they bind a large number of transactions under the chain with "Rollup" smart contracts xff0c; and then submit them to the main chain on a regular basis.

  我们需要知道的是:Layer 2 方案是将交易的执行(即速度较慢的部分)放在链下进行,而在链上只储存交易数据。这样一来,区块链就能得以扩容,因为我们不用再在链上执行每笔交易了。同时,这也让交易进程加快、成本降低,而且在必要时,Layer 2 方案还可以与以太坊主链进行通信。

What we need to know is that xff1a; Layer 2 is the execution of the transaction xff08; that is, the slower part of the transaction xff09; placing it under the chain for xff0c; and storing the transaction data only on the chain. This way xff0c; the block chain can expand xff0c; because we don't have to carry out every transaction on the chain. xff0c; this also allows the transaction process to accelerate and cost xff0c; and xff0c; Layer 2 can also communicate with the main chain in the district.

全貌

Panorama.

  如果到此你感觉头晕目眩、迷惑不解,也属于正常现象,因为将所有这些工具整合在一起本来就十分复杂,容易让开发者感到焦头烂额。但是不用担心,开发框架的不断问世将会切实提升开发者的工作体验。

If you get there, you're dizzy and confused xff0c; it's also normal xff0c; because the integration of all these tools is inherently complex xff0c; it makes it easier for developers to feel under stress. But don't worry about xff0c; the constant development of the framework will actually enhance the developers' work experience.

  比如说,Hardhat 就是一个能方便以太坊开发者搭建、部署并测试智能合约的开发框架。Hardhat 内置了「Hardhat 网络」,开发者可以用此网络将智能合约部署到本地网络上,而无需处理实时环境。不仅如此,它还搭载了一个强大的插件生态系统,可以为开发者提供更大的便利。同时,Hardhat 还具备 console.log() 功能,和 JavaScript 一样可以用于调试。

xff0c; Hardhat, for example, is a framework for the development of smart contracts that can be built, deployed and tested by the developers of the Tailinga. Hardhat has built up "Hardhat Network" & #xff0c; developers can use this network to deploy smart contracts to local networks xff0c; without having to deal with real-time environments. Not only xff0c; it also carries a powerful plugin ecosystem xff0c; it makes it easier for developers. xff0c; Hardhat also has console.log() functions #xff0c; and JavaScript can be used for testing.

  当然,这仅仅只是开始,我希望开发者工具在未来能有更好的发展。

Of course #xff0c; it's just the beginning #xff0c; I hope the developers' tools will be better developed in the future.

总结

Summary

  很多人花了几个月的时间才搞清楚工具型区块链是什么,所以如果你是一个入门级的 DApp 开发者,那么我希望这篇文章能为你省去部分时间。既然如此,那就开始 DApp 的搭建吧!

It took many months to figure out what the tool block chain is xff0c; so if you're an entry-level DApp developer xff0c; then I hope this article will save you some time. xff0c; then start building the Dapp xff01;

参考https://mirror.xyz/0x891dDE39445f54bc6f1b73e89398f96e7851B4ba/6ZV0b8k87b9X2dupMgFrjenayxrFbNQFj4G6gGFqSsY

Reference:

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • DDO在新加坡上市真假,欧意交易所能交易数字期权吗?

    DDO在新加坡上市真假,欧意交易所能交易数字期权吗?
    然而,对于DDO在新加坡的列名是否真实存在争议。 据报道,有人质疑DDO的数字选项是否真的上市,其背景是否经过了彻底调查。 首先,有报告说,DDO数字选项清单仅仅是一种宣传手段,没有找到DDO交易的平台,这就对DDO的真正清单提出了疑问。 其次,一些媒体调查了DDO数字选项的背景。 报告显示DDO数字选项发行人声称其数字选项是国家赞助的,但实际上,根据中国人民银行,虚拟货币相关业务是非法金融活动。 此外,DDO数字选项在视频号码等平台上广为传播,吸引了许多信徒的注意,然...
  • Griffin Gaming Partners计划为其第三支基金筹集5亿美元

    Griffin Gaming Partners计划为其第三支基金筹集5亿美元
    Pitchbook引用的6月8日《快链头条新闻》作为监管文件, 指出游戏风险投资公司Griffin赌博伙伴计划为其第三个旗舰基金筹集5亿美元, 比第二个基金少33%。 2021年,格里芬赌博伙伴从Web3游戏开发者Forte获得A回合资金1.85亿美元,并于2022年筹集了第二个旗舰基金,金额达7.5亿美元,此时风险资本家对Web3和加密游戏的热情达到顶峰。...
  • 比过山车还狠!比特币价格再次暴跌

    比过山车还狠!比特币价格再次暴跌
      上周日,比特币的价格创造了3000美元的历史新高,随后就开始各种高台跳水了。Last Sunday, the price of Bitcoin created a record high of $3,000, and then began to dive on all the high platforms.   据外媒报道,本周一,比特币价格一度下跌到2526.4美元,最高跌幅高达14.5%,这创造了2015年1月以来最大跌幅。According to external...
  • 加密货币之王重回王位:比特币飙升至 71,000 美元,还能再涨多少?

    加密货币之王重回王位:比特币飙升至 71,000 美元,还能再涨多少?
    比特币是市场上最大的加密货币,它再次打破了重要的7万美元门槛。 在短短的四舍五入(67,000美元到69,000美元之间)之后,价格在这一水平上遇到了强烈的抵制。 然而,势头的不断增强表明,比特币可能形成一个超过70 000美元的板块,为重新测试下一个抵抗阵地71 300美元和3月份可能攀升到历史最高点73 700美元铺平了道路。 问题仍然是:比特币能否维持预期的上升趋势并继续大幅上升?    分析家预计比特币价格将上升到74,400美元。 加密货币分析师Ali M...
  • 几张图看懂区块链技术到底是什么?https://www.cnblogs.com/behindman/p/8873191.html

    几张图看懂区块链技术到底是什么?https://www.cnblogs.com/behindman/p/8873191.html
    “区块链”的概念可以说是异常火爆,好像互联网金融峰会上没人谈一谈区块链技术就out了,BAT以及各大银行还有什么金融机构都在开始自己的区块链研究工作,就连IBM最近也成立了自己的区块链研究实验室,但其实区块链到底是什么?大家或许并不清楚,停留在雾里看花的状态。从今天开始,就让我们一起走进区块链,揭开区块链的神秘面纱吧!The concept of a block chain can be described as an unusually hot one, as if no...
标签列表