erc173

    0

    0

    lucycodes42

    Solidity Code Snippets

    Shortcut: erc173_draft

    // https://eips.ethereum.org/EIPS/eip-173
    // https://github.com/0xcert/ethereum-erc721/blob/master/src/contracts/ownership/ownable.sol (this example)
    // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
    // https://github.com/FriendlyUser/solidity-smart-contracts//blob/v0.2.0/contracts/other/CredVert/Ownable.sol
    // SPDX-License-Identifier: MIT
    pragma solidity >=0.5.0 <0.8.0;
    
    /**
     * @dev The contract has an owner address, and provides basic authorization control whitch
     * simplifies the implementation of user permissions. This contract is based on the source code at:
     * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ownership/Ownable.sol
     */
    contract Ownable
    {
    
      /**
       * @dev Error constants.
       */
      string public constant NOT_CURRENT_OWNER = "018001";
      string public constant CANNOT_TRANSFER_TO_ZERO_ADDRESS = "018002";
    
      /**
       * @dev Current owner address.
       */
      address public owner;
    
      /**
       * @dev An event which is triggered when the owner is changed.
       * @param previousOwner The address of the previous owner.
       * @param newOwner The address of the new owner.
       */
      event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
      );
    
      /**
       * @dev The constructor sets the original `owner` of the contract to the sender account.
       */
      constructor()
        public
      {
        owner = msg.sender;
      }
    
      /**
       * @dev Throws if called by any account other than the owner.
       */
      modifier onlyOwner()
      {
        require(msg.sender == owner, NOT_CURRENT_OWNER);
        _;
      }
    
      /**
       * @dev Allows the current owner to transfer control of the contract to a newOwner.
       * @param _newOwner The address to transfer ownership to.
       */
      function transferOwnership(
        address _newOwner
      )
        public
        onlyOwner
      {
        require(_newOwner != address(0), CANNOT_TRANSFER_TO_ZERO_ADDRESS);
        emit OwnershipTransferred(owner, _newOwner);
        owner = _newOwner;
      }
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.