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?


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});

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.