无法在全球更改数组元素



当前在以太坊DAPP上工作。我有一个坚固的文件,如下

pragma solidity ^0.4.11;
contract ArrayOfBytes32 {
    address creator;
    bytes32[10] bytesArray; // size must be fixed

    function getArray() constant returns (bytes32[10])
    {uint8 x = 0;
        while(x < bytesArray.length)
        {
            bytesArray[x] = "myString"; 
            x++;
        }
        return bytesArray;
    }
    function getValue(uint8 x) constant returns (bytes32)
    {
        return bytesArray[x];
    }
}

在此功能中,getarray()正确返回。但是函数getValue()总是返回默认值,即0000000。GetArray()中所做的更改不反映!!任何解决方案

getArray()删除constant修饰符。constant功能不会将状态写入区块链。

最新更新