1

I created a simple contract which has a simple state with a single int.

enter image description here

I gave it a value of 90 at the deployment time (constructor).

Now I went to the particular block in Rinkeby, and I could see the Bytecode of my contract code.

But I am not sure if other nodes can see that I had set the value to 90.

Or one can see it only if there is a getter for it?

I am sorry if my question is very basic. I have just got stared with Ethereum.

2

To add to @Andrey's answer, your contract makes it inconvenient to access the data. If it is your intention to make that easily accessible by other contracts and observers, you can make the visibility public with

uint public value

That will give everyone a helpful function that is functionally equivalent to:

function value() public view returns(uint) { return value; }

When you don't do that, it's harder for observers, but ...

All data is available to all full nodes who are independently validating transactions sent to your contract. They all independently conclude 90. Implicitly, anyone with the know-how to work at the miner/node software level or how to rumage around in raw storage in Solidity can find their way to that number.

Also, the data payload for the transaction that set the value to 90 is forever visible to everyone via a block explorer. Everyone can see 90 on its way to the setter functions.

Main takeaway? It's very tricky to keep a secret on the blockchain. private may be sort of misleading.

Hope it helps.

2

All blockchain data is public. Since your contract(and its state) is stored in the blockchain, variables are also public.

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.