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
as described in the web.js docs