0 votes
1 view
in Blockchain by (7k points)

I have a private parity node setup on my laptop. How can I make sure that there is 0 transaction fee whenever a transaction is posted in this private Ethereum blockchain, meaning that I can post a transaction giving "gas: 0"?

Example: Account A has 20 ether, Account B has 0 ether. When I transfer 10 ether from Account A to Account B, Account A now shows 9.980 and Account B shows 10.

How can I prevent the extra gas being deducted?

Any help is appreciated.

1 Answer

0 votes
by (14.5k points)

For controlling miners in a private network, customize them to accept transaction at gasPrice=0

--gasprice WEI denotes the minimum amount of Wei per Gas to be paid for a transaction which is to be accepted for mining.  

However, this change is configuration does not affect how gas works in the network. Basic functions still work the way they used to do. The difference that comes to picture is that clients will pay 0 per transaction and the miners will accept that. 

You may switch to Geth from Parity as in Geth the above configuration is supported completely. 

Code for Terminal 1 in Geth: 

$ geth --networkid 29462 --datadir "./data" --gasprice 0 --nodiscover --port 31313

<Output Truncated>

Code for Terminal 2 in Geth: 

$ 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

}

Hope this helps! 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...