0

my remix

pragma solidity ^0.4.24;

contract Foo {
    bytes32 foo;

    function setFoo(bytes32 _foo) public {
        foo = _foo;
    }

    function getFoo() public constant returns (bytes32) {
        return foo;
    }
}

my script

var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
web3.eth.defaultAccounbt = web3.eth.accounts[0];

var fooContract = web3.eth.contract([{
    "constant": true,
    "inputs": [],
    "name": "getFoo",
    "outputs": [{
      "name": "",
      "type": "bytes32"
    }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{
      "name": "_foo",
      "type": "bytes32"
    }],
    "name": "setFoo",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  }
]);

var foo = fooContract.at('0xe884fb988c3242bcd16a0e187b10e6261733477e');

my chrome console

foo.setFoo("hello world");
1

The issue is probably just this typo:

web3.eth.defaultAccounbt = web3.eth.accounts[0];

(a stray "b" in Accounbt)

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.