Discover more of Etherscan's tools and services in one place.
Sponsored
Contract Source Code:
File 1 of 1 : DocumentStore
pragma solidity ^0.4.24; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable 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); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @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 { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract DocumentStore is Ownable { string public name; string public version = "2.2.0"; /// A mapping of the document hash to the block number that was issued mapping(bytes32 => uint) documentIssued; /// A mapping of the hash of the claim being revoked to the revocation block number mapping(bytes32 => uint) documentRevoked; event DocumentIssued(bytes32 indexed document); event DocumentRevoked( bytes32 indexed document ); constructor( string _name ) public { name = _name; } function issue( bytes32 document ) public onlyOwner onlyNotIssued(document) { documentIssued[document] = block.number; emit DocumentIssued(document); } function getIssuedBlock( bytes32 document ) public onlyIssued(document) view returns (uint) { return documentIssued[document]; } function isIssued( bytes32 document ) public view returns (bool) { return (documentIssued[document] != 0); } function isIssuedBefore( bytes32 document, uint blockNumber ) public view returns (bool) { return documentIssued[document] != 0 && documentIssued[document] <= blockNumber; } function revoke( bytes32 document ) public onlyOwner onlyNotRevoked(document) returns (bool) { documentRevoked[document] = block.number; emit DocumentRevoked(document); } function isRevoked( bytes32 document ) public view returns (bool) { return documentRevoked[document] != 0; } function isRevokedBefore( bytes32 document, uint blockNumber ) public view returns (bool) { return documentRevoked[document] <= blockNumber && documentRevoked[document] != 0; } modifier onlyIssued(bytes32 document) { require(isIssued(document), "Error: Only issued document hashes can be revoked"); _; } modifier onlyNotIssued(bytes32 document) { require(!isIssued(document), "Error: Only hashes that have not been issued can be issued"); _; } modifier onlyNotRevoked(bytes32 claim) { require(!isRevoked(claim), "Error: Hash has been revoked previously"); _; } }
Please enter a contract address above to load the contract details and source code.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
My Name Tag:
Private Note:
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.