4

I am new to Ethereum dev.

I wrote the code below in my local node to transfer 1 ether between my two Rinkeby testnet.

From account: 0xffD8eb81304291AFcA2C4DA5D26B691b8CC81Bd5
It has 21 ether in Rinkeby (Hope this is sufficient).

// Environment
"web3": "^0.19.1"

Geth
Version: 1.7.2-stable
Git Commit: 1db4ecdc0b9e828ff65777fb466fc7c1d04e0de9
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.2
Operating System: darwin
GOPATH=
GOROOT=/usr/local/Cellar/go/1.9.2/libexec

My nodejs code:

var Web3 = require('web3');
var util = require('ethereumjs-util');
var Tx = require('ethereumjs-tx');
var lightwallet = require('eth-lightwallet');
var txutils = lightwallet.txutils;

var web3 = new Web3(

new Web3.providers.HttpProvider('https://rinkeby.infura.io/qyft9l9yABZ7tJuoX8R4')
//Local RINKEYBY
//new Web3.providers.HttpProvider('http://127.0.0.1:8545')
);


var addr1 = '0xffd8eb81304291afca2c4da5d26b691b8cc81bd5';
var addr2 = '0xba5453837f30b2ba413c06567dd9ea812abf123f';
var privateKey = new Buffer('bf36e0ba1bb26ad4949df0d92554b8702cb595a23410ba8ecac8dbde0d607dfc', 'hex');

var rawTx = {
chainId: web3.toHex('4'),
gas: web3.toHex('21000'),
gasPrice: web3.toHex('25000000000'),
gasLimit: web3.toHex('90000'),
from: '0xffd8eb81304291afca2c4da5d26b691b8cc81bd5',
to: '0xba5453837f30b2ba413c06567dd9ea812abf123f',
value : web3.toHex(web3.toWei(1, "ether"))

}


var tx = new Tx(rawTx);
tx.sign(privateKey);
var serializedTx = tx.serialize();

web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
if (!err)
  console.log(hash); 
else 
  console.log(err);
});

I always end up with this below error msg :-(
Same happens for me in other private network and mainnet also.

Can you please tell how to get rid of this insufficient funds error.

Error: insufficient funds for gas * price + value at Object.InvalidResponse (/Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/web3/lib/web3/errors.js:38:16) at /Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/web3/lib/web3/requestmanager.js:86:36 at XMLHttpRequest.request.onreadystatechange (/Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/web3/lib/web3/httpprovider.js:118:13) at XMLHttpRequestEventTarget.dispatchEvent (/Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/xhr2/lib/xhr2.js:64:18) at XMLHttpRequest._setReadyState (/Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/xhr2/lib/xhr2.js:354:12) at XMLHttpRequest._onHttpResponseEnd (/Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/xhr2/lib/xhr2.js:509:12) at IncomingMessage. (/Users/antonyjohnson/Documents/development/angularjs/mean/todo-app/todo-api/node_modules/xhr2/lib/xhr2.js:469:24) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1056:12)

4

This isn't an coding error, you just havn't the 1 eth you try to send. And your GETH isn't in Rinkeby, you are in main network :

Network Id: 1

This is the id for main network. Rinkeby is 4. You can start geth with --rinkeby, it will automaticaly change network id, genesis, ...

  • The code is connected to rinkeby only and also the accounts I have used are from Rinkeby. The geth network id = 1 was coming when I used console command : geth version in my mac os console. – antjohns Dec 9 '17 at 16:47
  • "network id = 1 was coming when I used console command" yeah, what the console said is over all other information, because it is created by the node (geth it self), the client (geth attach) will just make it printable (beautifier the json). I verify now and with 18.xx of geth, on rikeby network id = 4 and main network is 1. For rinkeby address and main address, it is the same things, so you can have the same address for both network, juste balance will not shared. – Jorropo Dec 9 '17 at 22:29
  • Like you said i started get with --rinkeby <br/> console.log(web3.version.network); --->>> 4 But Still I get the same Error: insufficient funds for gas * price + value . :-( – antjohns Dec 10 '17 at 7:17
  • 1
    The issue is solved. I had mistakenly used the wrong private key for signing. – antjohns Dec 10 '17 at 13:43
0

I got the same error and I use private key with address 44'/1'/0'/0 I compare with trezor and r,s of singnature prameter is different. Do you have experiment in that. I use C library of trezor open source.

  • If you have a question post it separately. Link this question there if this is related. – Achala Dissanayake Aug 10 '18 at 12:35
  • I found problem that wrong Bip 44 path. The path finally is: 44'/1'/0'/0/0 – HoangLoc Sep 26 '18 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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