Tengo una estructura similar a esta típica fábrica.
contract Factory {
bytes32[] Names;
address[] newContracts;
function createContract (bytes32 name) {
address newContract = new Contract(name);
newContracts.push(newContract);
}
function getName (uint i) {
Contract con = Contract(newContracts[i]);
Names[i] = con.Name();
}
}
contract Contract {
bytes32 public Name;
string public numberString;
function Contract (bytes32 name) {
Name = name;
}
function setNumberString (string time){
numberString = time;
}
}
A esta estructura le agregué la función setNumberString
y la variable numberString
, con Web3 js he definido esto:
myContract = web3.eth.contract(ABIArray).at(contractAddress);
myContract.setNumberString(state, function(error, result){
if(!error)
console.log(result)
else
console.error(error);
})
Los ABIArray
y contractAddress
son del "contrato de contrato" creado, y cuando intento llamar a la función, obtengo este mensaje en el navegador de la Dapp:
Uncaught TypeError: myContract.setNumberString is not a function
Cuando intento hacer esto con un contrato normal no tengo ningún problema, ¿qué estoy haciendo mal? ¿Es posible llamar a la función de este contrato creado?
Esto puede ocurrir porque setNumberString
no está definido en su ABI.
Intenta usar esto
ABIArray=[{"constant":false,"inputs":[{"name":"time","type":"string"}],"name":"setNumberString","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"Name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"numberString","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"inputs":[{"name":"name","type":"bytes32"}],"payable":false,"type":"constructor"}];
Gawey
string public numberString;
? conmyContract.numberString
? o necesito modificar la matriz ABI nuevamente?Badr Bellaj