Day 2: Access Control
Counter.sol - a little better than "Hello World", right?
The goal: write a simple Counter contract - increment, decrement, reset -
with real access rules.
The Contract
// SPDX-License-Identifier: MIT pragma solidity ^ 0.8.0 ;
contract Counter { uint256 public count ; address public owner ;
constructor () { owner = msg . sender ; count = 0 ; }
function increment () public { count += 1 ; }
function decrement () public { require ( count > 0 , "Already zero" ); count -= 1 ; }
function reset () public { require ( msg . sender == owner , "Only owner can reset!" ); count = 0 ; } }
Enter fullscreen mode
Exit fullscreen mode
GitHub: github.com/alena-dev-soft/solidity-learn/contracts/02day/
What Actually Clicked
In the .NET world we use HttpContext.User to know who's making a request. In Solidity it's msg.sender - the wallet address of whoever called the method. No login system, no JWT, no sessions. Just a cryptographically verified address. The contract knows exactly who you are.…