Problems connecting dynamically created contract

o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
I have a Factory that creates Gizmo contracts...
contract Gizmo
{
int public val;
function Gizmo(int v) {
val = v;
}
}

contract Factory
{
Gizmo public gizmoAddr;
function Create(int _value) returns (Gizmo) {
gizmoAddr = new Gizmo(_value);
return gizmoAddr;
}
function getGizmoVal() constant returns (int) {
return gizmoAddr.val();
}
}
The gizmo creates fine and I can get a Gizmo.val returned through Factory.getGizmoVal().
However I can't hook into the Gizmo Instance itself in JS:
var gizmoABI = [{"constant":true, "inputs":[], "name":"val", "outputs":[{"name":"", "type":"int256"}], "type":"function"},
{"constant":true, "inputs":[], "name":"Val", "outputs":[{"name":"", "type":"int256"}], "type":"function"},
{"inputs":[{"name":"v", "type":"int256"}], "type":"constructor"}],
gizmoAddr,
gizmoInst,
gizmo = web3.eth.contract(gizmoABI);

function create() {
var val = document.getElementById('key').value;
gizmoAddr = contracts['Factory'].contract.Create(val,{from: web3.eth.accounts[0],gas:200000});
gizmoInst = gizmo.at(gizmoAddr);
}
The gizmoAddr that is returned to JS is different from Factory.gizmoAddr which appears to be the correct one. However, trying gizmoInst = gizmo.at(gizmoAddr); in the console fails with
> gizmoInst = gizmo.at(gizmoAddr);	
Error: INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised

Comments

  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    Scratch that.....I can't connect to any contracts in Mix using:
    instance = web3.eth.contract(abi).at(address)
    Error: INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised

    as described in the web.js docs
Sign In or Register to comment.