Visibility and Privacy
Part of the Fundamentals section of Coddy's Solidity journey. Lesson 49 of 53.
Visibility controls which Solidity code can access a declaration through language-level interfaces. private state can be used by the contract that declares it, while public state adds a getter. Neither modifier encrypts blockchain data or makes a stored password safe.
Declare this at contract scope:
uint256 private referenceId;Use it inside the provided main function:
referenceId = 38;
console.log(referenceId);main can access the private variable because it belongs to the same contract. A separate contract cannot read it through a generated public getter, but blockchain observers can still inspect storage. These exercises teach language fundamentals, not a production security design.
private limits direct Solidity access; it does not provide confidentiality on a public blockchain.
Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
Practice on your own: Solidity playground