Glib pfp
Glib
@sushev
3. Encapsulation Encapsulation is the practice of restricting direct access to an object’s internal state and only allowing it through public functions. Solidity achieves this by using visibility modifiers (public, private, internal, and external). These modifiers control how and where state variables and functions can be accessed, helping improve contract security and integrity. solidity contract BankAccount { uint private balance; function deposit(uint amount) public { balance += amount; } function getBalance() public view returns (uint) { return balance; } } Here, balance is private, meaning it can’t be accessed directly from outside the contract. Instead, functions like deposit and getBalance manage and provide controlled access to the balance. https://www.geeksforgeeks.org/solidity-encapsulation/
0 reply
0 recast
0 reaction