In this section, we will discuss some common design and programming patterns for the smart contract programming language.
Common smart contract patterns
Access restriction
Access restriction is a solidity security pattern. It only allows authorized parties to access certain functions. Due to the public nature of the blockchain, all data on the blockchain is visible to anyone. It is critical to declare your contract function, state with restricted access control, and provide security against unauthorized access to smart contract functionality.
pragma solidity ^0.4.24;
contract Ownable {
address owner;
uint public initTime = now;
constructor() public {
owner = msg.sender;
}
//check if the caller is the owner of the contract...