I am running an ethereum node remotely using a start-up shell script. The command in the shell-script is as follows:
/usr/bin/geth --testnet --rpc --rpcport "5678" --rpcaddr "0.0.0.0" --rpccorsdomain "*" || logger "Geth not running"
Now my NodeJS app in local computer has the following code:
var express = require('express');
var router = express.Router();
var Web3 = require('web3');
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
var web3 = new Web3(new Web3.providers.HttpProvider("http://<IP>:<PORT>"));
}
var test_address = "ad9ffbd06d27d919b2f8d08c9abb5a4a90410eb1";
router.get('/', function(req, res) {
res.render('index', { title: 'Balance' });
});
router.get('/check', function(req, res) {
/*var coinbase = web3.eth.coinbase;
var balance = web3.eth.getBalance(coinbase);*/
//var balance = /*web3.fromWei(web3.getBalance(web3.coinbase));*/ web3.eth.checkAllBalances();
/*var coinbase = web3.eth.coinbase;*/
//var balance = web3.eth.getBalance(test_address);
/*web3.eth.getCoinbase(function(error, result){
if(error)
res.send("Error: "+error);
else
res.send("Result: "+result);
});*/
var block = web3.eth.getBalance(test_address);
console.log(block)
});
module.exports = router;
Issue 1: Whenever I try to use the coinbase method (it is commented in above code) to get balance, it just says: Error: etherbase address must be explicitly specified I have already create an account using:
geth account new
As far as I understand, the default coinbase / etherbase will always be the first account created, so I can't really understand why am I getting this error.
Issue 2:
After creating the account, I made transfer of 10000 Ether to the new account from test.ether.camp website. Whenever I check the balance of the new account from ether camp website, it shows 10000 Ether balance while the above code returns 0. Could it be that the block having the transaction information (the one I made from ether camp to my account) has not been downloaded in my node ? Or is there something wrong I am doing here?
Thanks in advance,