以太坊:交易成本如何计算 Jan 24, 2024 19:53:06 GMT -8 Quote Select PostDeselect PostLink to PostMemberGive GiftBack to Top Post by account_disabled on Jan 24, 2024 19:53:06 GMT -8 这篇关于以太坊交易成本的文章最初发表在Bruno 的 Bitfalls 网站上,经许可转载于此。 发送比特币交易时,其费用与其大小成正比。输入和输出越多,成本就越高。再加上待处理交易的因素,仅凭这两个因素,交易费用就会飙升。 建议您在深入了解本文的其余部分之前阅读以下材料,以例如上面的i+j是一个求和运算,便更好地理解我们将提到的术语。 什么是加密货币? 什么是区块链以及它如何运作? 什么是以太坊?它与比特币有何不同? 什么是挖矿?PoW 和 PoS 挖矿有什么区别? 编程术语(变量、循环)的基本知识也可能会派上用场。 JavaScript 对于以太坊,考虑到我们正在讨论协议中的编程语言,可能需要非常少的文本或代码(这在 BTC 领域是非常便宜的)来实现非常高的计算要求。让我们看看这个循环,例如然后再做一次”。如果为 0,则该循环将执行 1000 次i;如果为负数,则该循环将执行更多次。 为了以公平的方式支付这种计算成本——因为它必须同时在所有矿工的机器上执行,并且他们在上面花费资源和时间——引入了天然气的概念。Gas 用于支付 EVM 内这些所谓的 WhatsApp 号码数据 智能合约(以太坊程序)的执行费用。例如上面的i+j是一个求和运算,每次执行需要花费 3 个 Gas,所以执行 1000 次需要花费 3000 个 Gas。 为了正确解释gas,我们首先介绍一下EVM。 评估值 EVM 代表以太坊虚拟机。但虚拟机到底是什么? 虚拟机 虚拟机是在特定计算机上运行的软件,其中包含完全封装在主计算机内的另一个操作系统。例如,虚拟机允许您在 Linux 中运行 Windows、在 Windows 中运行 Linux、在 macOS 上运行 Windows(如下图所示)或任何其他组合。 Learn to Code with JavaScript macOS 内的 Windows 我们使用勒索软件。此外,例如,VM 允许我们在 Linux 上使用 Windows 游戏,或者允许我们轻松地在同一编程语言环境的不同版本中进行编程,而不会混淆它们。 评估值 以太坊虚拟机内置于在以太坊协议上运行的软件中。它执行智能合约——用 Solidity 语言编写的以太坊程序。EVM 包含在以太坊网络的完整节点中,在其中执行这些以太坊用户编写的程序。 以太坊的任何矿工都会同时执行智能合约代码。这意味着以太坊程序(dapps - 去中心化应用程序)同时在每个人的计算机上执行(去中心化)。 然而,这些程序的执行并不是免费的。矿工花费自己的电力、时间和硬件来做到这一点。为了支付他们执行计算机指令的努力(例如“将值 5 存储到变量 X 中”),引入了Gas的概念。 天然气、以太币和 GWei Gas是计算机需要执行的特定操作的成本单位,当我们广播包含以太坊程序的交易以运行 dapp 时,它会执行此指令。例如,将两个数字相加。