SilentCicero / ethereumjs-accounts

A simple module for creating, managing and using Ethereum accounts in browser.
MIT License
150 stars 58 forks source link

Gas price too low for acceptance #9

Open michbil opened 9 years ago

michbil commented 9 years ago

When making signTransaction for transaction like that:

{ from: '0xc40e6bd934b31b312bfe55441fc086b19aa4df4d', 
 to: '0x2ada84514b9955a7c1770bf718d1fbe49e770462',
data: '...' 
nonce: '0x0' }

getting error Gas price too low for acceptance. So here is the question, how to process correctly transactions without specified gasPrice in txParams

SilentCicero commented 9 years ago

Hmm, I'll have to look into this. I think 'gas' is required with most Ethereum clients as the underlying method is not sendTransaction in geth, for example, but pushTx. Because it's raw and not treated I believe a 'gas' value must be specified.

michbil commented 9 years ago

Overcame this problem by manually setting gas price in signTransaction()

if (!tx_params.gasPrice) {
     tx_params.gasPrice = formatHex(new BigNumber(web3.toWei(60, 'gwei')).toString(16));
}

But another question, how to set optimal gas price, if i set gas price lower than 50 gwei, my transaction is rejected with 'Gas price too low for acceptance'

SilentCicero commented 9 years ago

@michbil are you using the testnet or live frontier net? Is it local? Are you setting the gasprice in a gen-block.

I think there are still gasLimit (gas) restrictions on the frontier net, although I could be wrong. The gasPrice should be set to the default price. You can retrieve the default gas price like so:

web3.eth.getGasPrice(err, result){ if(!err) var gasPrice = result; }

Many dApps will grab this and save it locally first, and use the saved value with their tx's elsewhere in the app.

michbil commented 9 years ago

I'm using live network. Will try using getGasPrice one more time.