Bitcoin Forum
June 18, 2024, 09:30:40 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Calculating gas  (Read 368 times)
NewbieTreider (OP)
Member
**
Offline Offline

Activity: 89
Merit: 10


View Profile
July 26, 2016, 09:34:03 PM
 #1

Sorry for the question, I know that it's a newbie question but I readed a lot of information and I can't tranfer all my eth balance, and I don't know exactly what I'm doing wrong.

I used this in geth:

eth.sendTransaction({from:eth.coinbase, to:"address", value: eth.getBalance(eth.coinbase)-(21000*50000000000)})

And I get: "Insufficient funds for gas * price + value"

I specify also the gas amount and the price:

eth.sendTransaction({from:eth.coinbase, to:"address", value: eth.getBalance(eth.coinbase)-(21000*50000000000) gas:21000 gasPrice:5000000000})

But I get the same error. I know that I need to use some gas in my transaction and so, but I don't know how exactly calculate the correct amount.

Anyone can help me?

TIA

Biodom
Legendary
*
Offline Offline

Activity: 3794
Merit: 3976



View Profile
July 26, 2016, 09:45:09 PM
 #2

use this to send 1 eth, substitute 1 with 5.24 if you want to send 5.24 eth:

Code:
eth.sendTransaction({from: eth.coinbase, to: "anotheraddress", value: web3.toWei(1, "ether"),gas:22000,gasPrice:web3.toWei(21,"Shannon")})

this will send from your (synced!) main geth account to anotheraddress.
21 Shannon or 21 gwei will do right now.

somehow getbalance transaction never worked for me.
NewbieTreider (OP)
Member
**
Offline Offline

Activity: 89
Merit: 10


View Profile
July 26, 2016, 10:21:26 PM
 #3

use this to send 1 eth, substitute 1 with 5.24 if you want to send 5.24 eth:

Code:
eth.sendTransaction({from: eth.coinbase, to: "anotheraddress", value: web3.toWei(1, "ether"),gas:22000,gasPrice:web3.toWei(21,"Shannon")})

this will send from your (synced!) main geth account to anotheraddress.
21 Shannon or 21 gwei will do right now.

somehow getbalance transaction never worked for me.

Ok, thank you for your answer!, but if I put my total wallet amount instead of 1, I get the same error...

eth.getBalance(eth.coinbase) runs perfectly in my server, but I get the same error...

I tried also this:

eth.sendTransaction({from: eth.coinbase, to: "destAdrress", value: eth.getBalance(eth.coinbase)-(22000*web3.toWei(21,"Shannon")) , gas:22000 , gasPrice:web3.toWei(21,"Shannon")})

And then, the same error... Sad

"Insufficient funds for gas * price + value"

and web3.toWei(21,"Shannon") runs fine, I get:

"21000000000"

and eth.getBalance(eth.coinbase) runs perfectly to me!

No serious problem about this because at the end of the day I can transfer the whole number without decimals Wink, but I would like to know how I can transfer all my wallet.

Another idea?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!