¿Puedo llamar a una función dentro de un contrato creado?

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 setNumberStringy 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 ABIArrayy contractAddressson 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?

Respuestas (1)

Esto puede ocurrir porque setNumberStringno 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"}];
Buen arreglo, mi ABIArray estaba mal. ¿ Puedo acceder a string public numberString; ? con myContract.numberString? o necesito modificar la matriz ABI nuevamente?
acceda a él con myContract.numberString()