Problems connecting dynamically created contract

o0ragman0oo0ragman0o Posts: 1,221 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"}],
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 =;
The gizmoAddr that is returned to JS is different from Factory.gizmoAddr which appears to be the correct one. However, trying gizmoInst =; in the console fails with
> gizmoInst =;	
Error: INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised


Sign In or Register to comment.