简体   繁体   English

为什么在私有以太坊区块链上部署智能合约需要消耗gas费,而调用不需要?

[英]Why does the deployment of smart contracts on the private Ethereum blockchain need to consume gas fee, while the invocation does not?

Why does the deployment of smart contracts on the private Ethereum chain need to consume gasoline, while the invocation does not?为什么在私有以太坊链上部署智能合约需要消耗gas,而调用不需要?

When you're deploying a contract, you're sending a transaction , effectively storing the contract bytecode in the network.当你部署一个合约时,你正在发送一个交易,有效地将合约字节码存储在网络中。 All transactions cost gas fees as a reward for the miner/validator who executes it and publishes it to the network.所有交易都需要支付 gas 费用,作为对执行交易并将其发布到网络的矿工/验证者的奖励。

When you're invoking a contract function, you can do it two ways:当您调用合约 function 时,您可以通过两种方式进行:

  • read-only gas-free call that is not processed by a miner/validator - only by a node that your app is connected to.不由矿工/验证者处理的只读无气体调用- 仅由您的应用程序连接到的节点处理。 You don't pay any gas fees, but also cannot store any changes (eg token transfers)您无需支付任何 gas 费用,但也不能存储任何更改(例如代币转移)
  • read-write transaction that costs gas fees as a reward for the miner/validator读写交易,花费gas费作为矿工/验证者的奖励

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM