Can't make contract instance

YarkoLYarkoL Member Posts: 9
Hi

I'm following the Geth Frontier tutorial, and working out
the Greeter example.

I use the web compiler at http://chriseth.github.io/cpp-ethereum/ to get the bytecode and
ABI. So I put the output as the argument:
> greeterContract = eth.contract('[{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"input","type":"bytes32"}],"name":"greet","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[],"type":"constructor"}]');
and it returns
{
  abi: '[{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"input","type":"bytes32"}],"name":"greet","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[],"type":"constructor"}]',
  new: [Function],
  at: [Function]
}
but when I try to instantiate
> var greeterInstance = greeterContract.at(greeterAddress)
it gives me
TypeError: 'filter' is not a function
    at <unknown>
    at <unknown>
    at at (<anonymous>:-47702:-57)
    at <anonymous>:1:23
Any ideas?





Comments

  • YarkoLYarkoL Member Posts: 9
    Well, I installed solc and now everything
    seems to be OK.

    Either the output format of the online compiler
    is not working or I had fat fingers.
    > greeterContract = eth.contract(greeterCompiled.greeter.info.abiDefinition)
    {
      abi: [{
        outputs: [ ],
        type: 'function',
        constant: false,
        inputs: [ ],
        name: 'kill'
      }, {
        outputs: [{
          name: '',
          type: 'bytes32'
        } ],
        type: 'function',
        constant: false,
        inputs: [{
          name: 'input',
          type: 'bytes32'
        } ],
        name: 'greet'
      }, {
        outputs: [{
          name: '',
          type: 'address'
        } ],
        type: 'function',
        constant: true,
        inputs: [ ],
        name: 'admin'
      }, {
        inputs: [ ],
        type: 'constructor'
      } ],
      new: [Function],
      at: [Function]
    }
    > greeterInstance = greeterContract.at(greeterAddress)
    {
      address: '0xdbd575ffb7195cb6fa26fa959c8014c4a88a9f85',
      kill: [Function],
      greet: [Function],
      admin: [Function]
    }
  • adrianmcliadrianmcli Member Posts: 8
    I had the same issue. And I solved it by looking at my greeterContract. Apparently I did the eh.contract on it twice.

    As a result, the thing I was trying to do ".at()" to was not an ABI Array. But it was an ABI Array wrapped inside an object.

    Filter only works on Arrays in Javascript. So that's why that happened.
Sign In or Register to comment.