簡體   English   中英

如何確保交易在私有以太坊區塊鏈中收取0費用?

[英]How to make sure transactions take 0 fee in a private Ethereum blockchain?

我的筆記本電腦上有一個私有奇偶校驗節點。 如果在這個私有以太坊區塊鏈中發布交易 ,我怎樣才能確保有0交易費用 ,這意味着我可以發布一個給出“gas:0”的交易?

示例:帳戶A有20個以太,帳戶B有0個以太。 當我將10以太從賬戶A轉賬到賬戶B時,賬戶A現在顯示9.980,賬戶B顯示10。

如何防止額外的氣體被扣除?

任何幫助表示贊賞。

您可以控制專用網絡中的礦工,因此您只需要自定義它們以接受gasPrice = 0的事務。

Parity文檔中

--gasprice WEI                   Minimum amount of Wei per GAS to be paid for a
                                 transaction to be accepted for mining. Overrides
                                 --basic-tx-usd.

請注意,這並不會改變天然氣本身在網絡中的工作方式。 您仍然有氣體限制,可以產生氣體錯誤。 唯一的區別是,客戶說它將在交易中為天然氣支付0並且礦工保持它願意以0價格接受交易。

編輯 - 發表評論:

不可否認,我使用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以太。不支付任何費用。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM