On occasions you might have encountered the "Invalid Address", while executing any contract, either you have developed or the existing ones in either dapp applications or even in geth console.

There are two possible cases when you might get this error.


  1. The error is thrown by the method itself complaining of the address passed to it, is wrong.
  2. You try to execute a transaction method of a contract.

1. This first case is a very common scenarios when the function itself is expecting an address of which the operation needs to be performed on, for example web3.eth.getBalance(); This function like many other would through an error which would look like the trace as below.

> eth.getBalance()
invalid address
at web3.js:3887:15
at web3.js:4939:28
at web3.js:4938:12
at web3.js:4964:18
at web3.js:4989:23
at [[anonymous]]:1:1

It means that it was not provided with the address of which it needs to find the balance,in other words it could not able to parse the address, so in order to solve this problem, we got to provide the external account address like the format below.

> eth.getBalance("0xf8b99c16bcfc9855827a6558ff1eeb117449db35"); 9.0000000366728210742809152e+30

2. The other reason is if the contracts method is  transactional, and every transactional method invocations in contracts, needs the account address or the sender address. For example , the following contract 


contract TestContract{

    uint public data;

    function Test(){



function setData(uint param){




And the following javascript code while executed at the console.

var testcontractContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"param","type":"uint256"}],"name":"setData","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"data","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"Test","outputs":[],"type":"function"}]).at("0x0e1c2c0343cfe536f0a7af675f6686654eed241c");

testcontractContract.data(); // would return 0 , 

testcontractContract.setData(4);// would throw invalid address error if your eth.defaultAccount is not set.

You can invoke  eth.defaultAccount="0xAccountNumber"; // execute this at your console, with the actual account address

After this you can try executing the setData() method which would work after words.