4

I want to get the error message "Intrinsic gas too low" during a eth.sendTransaction call.

Is it possible to simulate the condition of having run out of gas in a private blockchain scenario?

Can someone please point the way to understand this and other possible edge cases?

EDIT -

web3.fromWei(eth.getBalance(eth.accounts[0]), "ether") 21

eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], gas:100000, value: web3.toWei(10, "ether")})

miner.start(1); admin.sleepBlocks(1); miner.stop();

web3.fromWei(eth.getBalance(eth.accounts[0]), "ether") 21

Why did my coinbase account balance remain 21?

2
  • lets call it resend not refill
    – niksmac
    Apr 11, 2016 at 17:04
  • If your question is about how to simulate out of gas events on a private blockchain, please revise your question inkluding the title. it can be reopened any time.
    – q9f
    Apr 12, 2016 at 13:04

1 Answer 1

5

Resend your transaction specifying a higher gas amount.

If you omit the gas parameter from the eth.sendTransaction(...) call, a default of 21000 is used for plain vanilla transactions.

To simulate running out of gas:

> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], gas:21000, value: web3.toWei(10, "ether")})
"0xcff42095692bb7ae72bbebbdbc7e177780e3d55859b96d7bfe561c695462d569"

> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], gas:1000, value: web3.toWei(10, "ether")})
Intrinsic gas too low
    at InvalidResponse (<anonymous>:-81662:-108)
    at send (<anonymous>:-156322:-108)
    at sendTransaction (<anonymous>:-133322:-108)
    at <anonymous>:1:1

> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], gas:100000, value: web3.toWei(10, "ether")})
"0x03e337d75ed319b15029bdca7c491e48acde4cfa44594f50df4cfb7aac5d7f53"

When you send your transaction, you should get a transaction hash.

You may have to leave your miner running for a few more blocks. Remove your admin.sleepBlocks(1); miner.stop(); statement.

If the transaction is successful, you will get something like the following result - the first call to eth.getTransaction(...) shows the transaction has not been mined yet (blockNumber is null). The second call shows the mined transaction (blockNumber is 1476). After this, your account should have the amount deducted.

> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], gas:100000, value: web3.toWei(10, "ether")})
I0412 23:36:08.702030   21319 xeth.go:1028] Tx(0x511ac8d69452f0791b57ab62e7c5261119463696c01ed81fb1e58d637d46cab5) to: 0x043f7fdc6e789060bfad91f7bba100d20a1cdf18
"0x511ac8d69452f0791b57ab62e7c5261119463696c01ed81fb1e58d637d46cab5"
> eth.getTransaction("I0412 23:36:18.881647   21319 worker.go:348] 🔨  Mined block (#1475 / 37440f0d). Wait 5 blocks for confirmation
VM STAT 0 OPs
I0412 23:36:18.882734   21319 worker.go:569] commit new work on block 1476 with 1 txs & 0 uncles. Took 1.023896ms
VM STAT 0 OPs
I0412 23:36:18.883282   21319 worker.go:569] commit new work on block 1476 with 1 txs & 0 uncles. Took 488.218µs
0x511ac8d69452f0791b57ab62e7c5261119463696c01ed81fb1e58d637d46cab5")
{
  blockHash: null,
  blockNumber: null,
  from: "0x8d15cd39bdb00d5362775002c342c168ee707400",
  gas: 100000,
  gasPrice: 20000000000,
  hash: "0x511ac8d69452f0791b57ab62e7c5261119463696c01ed81fb1e58d637d46cab5",
  input: "0x",
  nonce: 4,
  to: "0x043f7fdc6e789060bfad91f7bba100d20a1cdf18",
  transactionIndex: null,
  value: 10000000000000000000
}
> I0412 23:36:23.527844   21319 worker.go:348] 🔨  Mined block (#1476 / ca7817a9). Wait 5 blocks for confirmation
I0412 23:36:23.528429   21319 worker.go:569] commit new work on block 1477 with 0 txs & 0 uncles. Took 505.461µs
I0412 23:36:23.528831   21319 worker.go:569] commit new work on block 1477 with 0 txs & 0 uncles. Took 312.822µs
> eth.getTransaction("0x511ac8d69452f0791b57ab62e7c5261119463696c01ed81fb1e58d637d46cab5")
{
  blockHash: "0xca7817a90043b4c069e581d3ceb9bae0d147cd26f10a439410909d06fdaac5d0",
  blockNumber: 1476,
  from: "0x8d15cd39bdb00d5362775002c342c168ee707400",
  gas: 100000,
  gasPrice: 20000000000,
  hash: "0x511ac8d69452f0791b57ab62e7c5261119463696c01ed81fb1e58d637d46cab5",
  input: "0x",
  nonce: 4,
  to: "0x043f7fdc6e789060bfad91f7bba100d20a1cdf18",
  transactionIndex: 0,
  value: 10000000000000000000
}

You should also see commit new work on block 1476 with 1 txs & 0 uncles when your transaction is included in the mined block.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.