I am not able to change array elements globally

0 votes

i have a solidity file as below

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];
    }
}

in this function getArray() returns correctly. But function getValue() always returning default value ie 0000000. changes made in getArray() are not reflected.

Oct 9, 2018 in Blockchain by slayer
• 29,050 points
15 views

1 answer to this question.

0 votes

Remove the constant modifier from getArray()constant functions do not write state to the blockchain.

answered Oct 9, 2018 by Omkar
• 67,120 points

Related Questions In Blockchain

+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
247 views
0 votes
1 answer

Angular 4: not able to iterate over an array

Replace this : <div *ngFor="let price of prices"> ...READ MORE

answered Sep 3, 2018 in Blockchain by digger
• 27,620 points
49 views
+4 votes
2 answers

I am unable to connect Ganache with Truffle/Npm Dev server. Pls help.

The issue is at CurrentProvider. Give the url ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 17,010 points

edited Oct 11, 2018 by Omkar 268 views
0 votes
1 answer

Why is it downloading the blocks when I am trying to deploy the ethereum private network?

Once you have installed the Ethereum wallet, ...READ MORE

answered May 3, 2018 in Blockchain by Shashank
• 10,330 points
26 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
105 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,120 points
54 views
+1 vote
3 answers

Not able to read a file from my assets folder

Hi.. I faced a similar problem in ...READ MORE

answered Oct 25, 2018 in Blockchain by Shrikanth
473 views
0 votes
1 answer

Not able to invoke a contract in Ethereum Private chain using geth

Hope this helps: contract mortal { /* ...READ MORE

answered Oct 22, 2018 in Blockchain by Omkar
• 67,120 points
35 views