Access level for State variables
Access Modifiers | Description |
public | Can use public state variables directly from within the contract and access them through the related getter function from external contract or client code. |
internal | The contract and any inherited contract can access Internal state variables. This is the default level for state variables. |
private | Only members of the same contract—not inherited contracts—can access private state variables. |
Access level for Functions
Access Modifiers | Description |
external | An external function is exposed in the contract interface, and you can only call it from external contracts or client code but not from within the contract. |
public | A public function is exposed in the contract interface and you can call it from within the contract or from external contracts or client code. This is the default accessibility level for functions. |
internal | An internal function isn’t part of the contract interface, and it’s only visible to contract members and inherited contracts |
private | A private function can only be called by members of the contract where it’s been declared, not by inherited contracts. |
Example:
contract BiasTekCoin {
function transfer(address _to, uint256 _amount) public {} //accessible internally and externally
function checkLimit(uint256 _amount) private returns (bool) {} //only accessible from within this contract
function validateAccount(address avcount) internal returns (bool) {} //accessible from this and inherited contracts
function freezeAccount(address target, bool freeze) external {} //only accessible externally
}
Blockchain Ethereum – Ví dụ về hàm Delegatecall trong solidity
Blockchain Ethereum (P4) – Kết Nối Các Node Sử Dụng Bootnode
Blockchain Ethereum (P3) – Cài Đặt Private Blockchain trên nền tảng Ethereum
Install web3 and nodejs
Sử dụng Virtual Box
Đọc sách 2021