1

After deploying a Smart Contract and knowing that:

address = 0x20e4ac9385ea45919b9709c2b38d3190efa42ee4
ABI = [{
        constant: false,
        inputs: [],
        name: "kill",
        outputs: [],
        payable: false,
        type: "function"
    }, {
        constant: true,
        inputs: [],
        name: "greet",
        outputs: [{...}],
        payable: false,
        type: "function"
    }, {
        inputs: [{...}],
        type: "constructor"
    }]

I want to call it, but first I need to instantiate it in a JS var like this:

var greeter = eth.contract([{ constant: false, inputs: [], name: "kill", outputs: [], payable: false, type: "function" }, { constant: true,inputs: [], name: "greet", outputs: [{...}], payable: false, type: "function" }, { inputs: [{...}], type: "constructor"}]).at("0x20e4ac9385ea45919b9709c2b38d3190efa42ee4");

but it throws this error:

(anonymous): Line 1:179 Unexpected token . (and 9 more errors)

It seems like a syntax error, maybe I missed something.

4
  • Are you literally using "[{...}]" for inputs and outputs? That looks like something's getting collapsed when the object is turned into a string. Sep 26, 2016 at 14:05
  • Yes, literally. Should I escape it or something? Sep 26, 2016 at 14:26
  • 1
    Where did you get that output? If it's your browser try clicking it to see what's down there. Sep 26, 2016 at 15:18
  • I used geth console Sep 26, 2016 at 15:33

1 Answer 1

1

I think I found what was the problem: lack of double quotes.

When instantiating the Smart Contract using the literal ABI from https://ethereum.github.io/browser-solidity/ everything works!

> var greeter = eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"type":"constructor"}]).at("0x20e4ac9385ea45919b9709c2b38d3190efa42ee4");

> greeter.greet();

Thanks!

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.