区块链中GAS介绍

来源:互联网 发布:python可以开发游戏吗 编辑:程序博客网 时间:2024/05/17 23:38

When a transaction takes place in Ethereum, a transaction cost must be paid to the client that executes the transaction on your behalf, committing the output of this transaction to the Ethereum blockchain.

当一个交易发生在以太坊,为了执行你自己的交易,这个交易的花销必须支付给客户端,保证交易的输出被部署到以太坊客户端上。

This cost is measure in gas, where gas is the number of instructions used to execute a transaction in the Ethereum Virtual Machine. 

这个费用是用gas来衡量的,gas是在以太坊虚拟机上执行一个交易所需要使用的指令的数量。

What this means for you when working with Ethereum clients is that there are two parameters which are used to dictate how much Ether you wish to spend in order for a tranaction to complete:

当以太坊运行的时候,有两个参数(控制当一个交易完成你希望发送的ETHER)被使用,对你来说意味着什么呢:

Gas price

This is the amount you are prepared in Ether per unit of gas. web3j uses a default price of 22,000,000,000 Wei (22 x 10-8 Ether). This is defined in ManagedTransaction.

你准备去花费每单位gas的ETHER数量,web3j使用一个默认的价格22,000,000,000 Wei (22 x 10-8 Ether)

就是1gas=22,000,000,000 Wei (22 x 10-8 Ether)

Gas limit

This is the total amount of gas you are happy to spend on the transaction execution. There is an upper limit of how large a single transaction can be in an Ethereum block which restricts this value typically to less then 6,700,000. The current gas limit is visible at https://ethstats.net/.

这个是你喜欢在交易调用时发送的gas总量。在以太坊区块中单个交易通常有一个上限值,设置为6700000Wei。

These parameters taken together dictate the maximum amount of Ether you are willing to spend on transaction costs. i.e. you can spend no more then gas price * gas limit. The gas price can also affect how quickly a transaction takes place depending on what other transactions are available with a more profitable gas price for miners.

这两个交易通常一起使用去控制在一个交易中你希望去花费的Ether的最大数量。例如,你可以花费不超过gas price*gas limit数量的Ether,gas价格也会影响交易发生的速度,这取决与对于矿工来说更有利可图的其他交易的价格,就是说gas价格越高,交易发生的速度越快。

You may need to adjust these parameters to ensure that transactions take place in a timely manner.

你可能需要调整这些参数以确保交易可以及时被处理。

翻译有错误的请大家指正。

原创粉丝点击