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,370 points
695 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
• 69,220 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
1,127 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
• 26,740 points
1,056 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,100 points

edited Oct 11, 2018 by Omkar 2,698 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,400 points
654 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
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
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
• 69,220 points
1,464 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
6,952 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
• 69,220 points
979 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP