struct testR{
bytes32 name;
int32 count;
}
testR[] public tests;
function createTest(bytes32[] names) external returns (bool success) {
uint256 len = names.length;
for (uint8 i=0;i<len;i++){
tests.push(testR({name: names[i], count: 0}));
}
return true;
}
Aquí está mi código. Cuando implemento este contrato en mi red privada, la función createTest simplemente no funciona, paso una matriz de cadenas convertidas a HEX, luego, cuando llamo a la matriz pública "pruebas", siempre me devuelve 0x y nulo. Si trato de compilar y ejecutar este contrato en Remix usando JVM, da este error:
undefined errored: VM error: invalid opcode.
invalid opcode The constructor should be payable if you send value.
The execution might have thrown.
Debug the transaction to get more information.
Supongo que hay algo mal con mi bucle, pero parece tan simple.
Acabo de reorganizar algunas cosas y el siguiente código funcionó para mí. También asegúrese de que realmente está ingresando una matriz o también obtendrá un error.
testR[] public tests;
struct testR{
bytes32 name;
int32 count;
}
function createTest(bytes32[] names) external returns (bool success) {
uint256 len = names.length;
for (uint8 i=0;i<len;i++){
tests.push(testR(names[i],0));
}
return true;
}
Alex Plejánov
el feto
Alex Plejánov