I am trying to copy stored values using the following internal value.

pragma solidity ^0.4.21;

contract test{

    event LogTest(
        bytes32[5] a

    bytes32[5]  attr;

    function attributes() internal {
        attr[0] = "0x0"; attr[1] = "0x1"; attr[2] = "0x2"; attr[3] = "0x3"; attr[4] = "0x4";

    function getA() public{


However, the log does not return the correct values. Instead, it returns the following:

"a": [

Why are the values incorrect?


That looks right to me. You're storing strings in the array, so they're stored in their ASCII representation. You can double check that the right string was stored by converting the output back to strings, here using web3.js in my browser:

> web3.toAscii('0x3078300000000000000000000000000000000000000000000000000000000000')
> web3.toAscii('0x3078310000000000000000000000000000000000000000000000000000000000')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.