您控制私有网络中的矿工,因此您只需自定义它们以接受 gasPrice = 0 的交易。
来自Parity documentation:
--gasprice WEI Minimum amount of Wei per GAS to be paid for a
transaction to be accepted for mining. Overrides
--basic-tx-usd.
请注意,这不会改变 gas 本身在网络中的工作方式。您仍然有 gas 限制,并且可能会产生 out of gas 错误。唯一的区别是客户说它会为交易支付 0 的 gas,而矿工留下来愿意以 0 的价格接受交易。
编辑 - 解决 cmets:
诚然,我使用 Geth 而不是 Parity,但这在 Geth 中有效,如果它曾经在 Parity 中得到支持然后被禁用,我会感到惊讶。您可能必须更改 Parity 源代码才能使其正常工作。或者,您可以切换到 Geth。
在下面的 Geth 中显示结果
1号航站楼
$ geth --networkid 29462 --datadir "./data" --gasprice 0 --nodiscover --port 31313
<Output Truncated>
2号航站楼
$ geth attach '//./pipe/geth.ipc'
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.2-stable-b8b9f7f4/windows-amd64/go1.9.2
coinbase: 0xd69cc234de15189f0ba998a41421961e89837fc5
at block: 79 (Tue, 06 Mar 2018 07:56:30 PST)
datadir: C:\cygwin\home\adamk\eth\private\node1\data
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
> web3.eth.getBalance('0x1b8c05505f86bf20c6a1110073cd6f9b3bf555df');
2000000000000000000
> web3.eth.sendTransaction({to: '0xd69cc234de15189f0ba998a41421961e89837fc5', from: '0x1b8c05505f86bf20c6a1110073cd6f9b3bf555df', gasLimit: 6000000, gasPrice: 0, value: web3.toWei(1, 'ether')});
"0x1eceea33aee0bd27feccd1d7aba371459090bb60af2cc18d63548112019ac2b9"
> web3.eth.getBalance('0x1b8c05505f86bf20c6a1110073cd6f9b3bf555df');
1000000000000000000
> web3.eth.getTransaction('0x1eceea33aee0bd27feccd1d7aba371459090bb60af2cc18d63548112019ac2b9');
{
blockHash: "0xad40ce3bfa30b2551dbd085c29ac1800add8b9bc464944625b82fb17df567823",
blockNumber: 897,
from: "0x1b8c05505f86bf20c6a1110073cd6f9b3bf555df",
gas: 90000,
gasPrice: 0,
hash: "0x1eceea33aee0bd27feccd1d7aba371459090bb60af2cc18d63548112019ac2b9",
input: "0x",
nonce: 0,
r: "0xc55b5a25f4c7670418f304db44d949f5a077c1b4c8cfcc89b486a84cccb59d22",
s: "0x7d1d5ee1ed54a0098299d44bd692fc0d3d249609b3c01810beb00180d11e2e35",
to: "0xd69cc234de15189f0ba998a41421961e89837fc5",
transactionIndex: 0,
v: "0x1b",
value: 1000000000000000000
}
(请注意,转账的发起者 0x1b8c05505f86bf20c6a1110073cd6f9b3bf555df 恰好减少了 1 个以太币。不支付任何费用。)