¿Es posible reducir el costo del gas de esta función? Actualmente está en 140k de gas para 20 elementos. (Soy nuevo en solidez)
uint8[1000] public array;
function Test(uint32[] index, uint8[] value) public {
for (uint i=0; i<index.length; i++) {
array[index[i]] = value[i];
}
}
¿Ha intentado crear una asignación del índice y el valor en lugar de crear dos matrices separadas? Funcionaría en ciertas situaciones, pero este código no me dice nada.
//Creating the mapping:
mapping(uint32 index => uint8 value) theMap;
//Then when setting the value:
theMap[index] = value;
//Then to get it back:
uint8 value = theMap[index]
Joost Vanhoutte
Gabe