#16 以太坊入门(Gas 和 Token)

导读:来自 MetaMask 的一篇文档 Learn the basics of blockchains and Ethereum。阅读时间约为 10 分钟。

原文与译文

What is gas, and why do I have to use it? / 什么是燃料,为什么我必须使用它?

Gas is the unit of measure for how much computational work is required to process transactions and smart contracts on the Ethereum Virtual Machine (EVM). More complex smart contracts, and code, will require more gas to execute, in the same way that a bigger, more powerful car takes more gas to run.

燃料是衡量在以太坊虚拟机(EVM)上处理交易和智能合约需要多少计算工作的单位。更复杂的智能合约和代码,将需要更多的燃料来执行,就像一辆更大、更强大的汽车需要更多的燃料来运行一样。

Calculating gas used to be very complicated, but as of the implementation of Ethereum Improvement Protocol (EIP) 1559 on August 4, 2021, it was greatly simplified. Essentially, you pay a base fee for every unit of gas, which is burned, or disappears, upon successful completion of the transaction. On top of the base fee, you add a priority fee, again per unit of gas, the value of which depends on how quickly you want the transaction to go through.

计算燃料过去是非常复杂的,但从 2021 年 8 月 4 日实施以太坊改进协议(EIP)1559 开始,它被大大简化。从本质上讲,你为每一个单位的燃料支付一个基本费用,在成功完成交易后,燃料会被燃烧,或消失。在基本费用的基础上,你再加上一个优先权费用,同样是每单位的天然气,其价值取决于你希望交易多快完成。

Here are some essential details for dealing with gas in MetaMask

下面是在 MetaMask 中处理燃料的一些基本细节

The gas limit / 燃料限制

The gas limit is the maximum number of units of gas you are willing to pay for in order to carry out a transaction or EVM operation. A standard transaction sending ETH normally costs 21,000 gas.

燃料限制是指你愿意为进行交易或 EVM 操作而支付的最大天然气单位数。一个发送 ETH 的标准交易通常需要 21,000 个燃料。

The max priority fee / 最大优先权费用

The max priority fee, also referred to as the “miner tip“, goes to the miner or validator, and incentivizes them to prioritize your transaction. Most often, the value you put in for “max priority fee” will be the amount you pay.

最大优先级费用,也被称为 “矿工小费”,是给矿工或验证者的,激励他们优先处理你的交易。大多数情况下,你输入的 “最大优先费 “的数值将是你支付的金额。

The max fee / 最大费用

The max fee is the total, global amount paid for your transaction. It is calculated as: (base fee + priority fee) x units of gas used. The difference between max fee per gas and base fee + max priority fee per gas is “refunded” to the user.

最大费用是为你的交易支付的总金额。它的计算方法是。(基本费用+优先费用) x 所用燃料单位。每个燃气的最大费用与基本费用+每个燃气的最大优先费用之间的差额将 “退还 “给用户。

Tokens / 代币

Aside from ether, the native currency of the Ethereum network, there are two main types of tokens that get used on Ethereum: ERC-20, which are “fungible” tokens and correspond to what people call “cryptocurrencies“, and ERC-721, the “non-fungible tokens“, the origin of the acronym NFT.

除了以太币,以太坊网络的原生货币,有两种主要类型的代币在以太坊上得到使用。ERC-20,这是 “可替换的 “代币,相当于人们所说的 “加密货币”,以及 ERC-721,”不可替换的代币”,也就是缩写 NFT 的起源。

The difference between the two is, of course, highly technical, but it boils down to the difference in the name. ERC-20 tokens are designed specifically to be fully interchangeable and liquid, the way a traditional fiat currency is. ERC-721 tokens, on the other hand, are specifically designed to be unique and non-replicable, but of course can be transferred between parties, often for significant value.

当然,两者之间的区别是高度技术性的,但归根结底是名称上的区别。ERC-20 代币被专门设计为完全可互换和流动的,就像传统法币那样。另一方面,ERC-721 代币被专门设计成唯一的、不可复制的,但当然可以在各方之间转让,往往价值不菲。

京ICP备12052177号-1