Tengo una función simple que imprime byte a byte el valor de bytes16 0x20010db80000000000000000000000001 y obtengo el siguiente resultado.
['0x20', '0x01', '0x0d', '0xb7', '0xff', '0xff', '0xff', '0x65' ]
[ '0x20', '0x7e', '0x22', '0x36', '0x66', '0xc0', '0x00', '0x00' ]
no debe ser??
['0x20', '0x01', '0x0d', '0xb8', '0x00', '0x00', '0x00', '0x00' ]
[ '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x01' ]
¿Por qué no?
Aquí el código:
function print1(bytes16 a) public
returns (bytes1,bytes1,bytes1,bytes1,bytes1,bytes1,bytes1,bytes1){
return (a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);}
function print2(bytes16 a) public returns
(bytes1,bytes1,bytes1,bytes1,bytes1,bytes1,bytes1,bytes1){
return (a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]);}
Paso a reproducir:
print1(0x20010db8000000000000000000000001);
print2(0x20010db8000000000000000000000001);
Probé tu código con Remix. Pero funciona bien. Si probó usando truffle (archivo de prueba de javascript), entonces debe usar print1 ("0x20010db80000000000000000000000001"), no olvide "". Tengo un problema similar con la matriz byte1 como aquí .
Y este es el resultado de la trufa con tu código,
además, tanto print1 como print2, es mejor que agregue "puro" para evitar advertencias, algo así como ...
function print1(bytes16 a) public pure
stefano angieri
Cronos