I have a contract which I'd like to be able to sum numbers submitted by any other address:

contract UnitCounter {
    mapping (address => uint256) public UnitsFrom;
    uint256 public TotalUnits;

    function submitUnits(uint256 Units) {
        UnitsFrom[msg.sender] = Units;
        TotalUnits += Units;

Using this as rough guidance, I followed the following steps on a private-net:

  1. Deploy the contract using mist
  2. Get the JSON Interface code using the "Show Interface" icon in mist
  3. Copy the address of the deployed contract 0x17d541b8aACFFe473e3dD32eBA83C82B51DB8EF9 on my private blockchain.
  4. On a Geth console:

    var abi=[ { "constant": false, "inputs": [ { "name": "Units", "type": "uint256" } ], "name": "submitUnits", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "TotalUnits", "outputs": [ { "name": "", "type": "uint256" } ], "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "UnitsFrom", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "type": "function" } ]

    var MyContract = web3.eth.contract(abi);
    var MyContractInstance = MyContract.at('0x17d541b8aACFFe473e3dD32eBA83C82B51DB8EF9');

I then get the following errors:

Error: invalid address
at web3.js:3887:15
at web3.js:3713:20
at web3.js:4939:28
at map ()
at web3.js:4938:12
at web3.js:4964:18
at web3.js:4989:23
at web3.js:4055:16
at apply ()
at web3.js:4141:16

What do these errors mean?

How should I debug from this point?

2 Answers 2


You need to add a transaction object to tell geth what account to use for the transaction:

MyContractInstance.submitUnits('10', {from: eth.accounts[0], gas:3000000});

You can also make this error go away this way, where you set your default account, so you don't have to add options {from:...} while interacting with your contract.

In your geth console :-

// default account set to first account in your geth accounts
eth.defaultAccount = eth.accounts[0]
// Note: If eth.accounts is empty, you can create a new account with personal.newAccount()
// default account set to coinbase(Etherbase), the default primary local account in geth
eth.defaultAccount = eth.coinbase

If you get this error next subsequently - Error: authentication needed: password or unlock, unlock your account.

In your geth console :-

// unlocks your account for calls/transactions after you give password 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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