Access control
Solidity is a high-level programming language specially designed for writing smart contracts on the Ethereum blockchain. It is heavily influenced by the syntax of popular language
// contracts/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyContract is Ownable {
function normalThing() public {
// anyone can call this normalThing()
}
function specialThing() public onlyOwner {
// only the owner can call specialThing()!
}
}Last updated