[Ethereum] Is data stored in a smart contract accesible without a ‘getter’ function

solidity

Lets say I store some data into a variable in a smart contract on creation. Since everything is public/stored on chain and it isn't encrypted with smart contract private key(Where is the private key for a contract stored?).

Would I be able to find this the data stored in the variable if I don't create a getter function to return the value? Or can I look through the storage associated with this contract and find the data?

I understand that if the variable is public, solidity automatically creates a getter.
But if the variable is private, it says that only the contract can read that data.

Best Answer

As you said, all the data is public. Anyone can read anything. From https://programtheblockchain.com/posts/2018/01/02/making-smart-contracts-with-public-variables/:

Due to the public nature of the Ethereum blockchain, it is impossible for a smart contract to contain truly hidden data. This is doubly true of state variables, because Ethereum provides a simple API to read them!

...

web3.eth.getStorageAt reads the storage for a contract by direct address lookup.

Related Topic