Skip to content

Instantly share code, notes, and snippets.

@eolszewski
Created August 22, 2018 17:00
Show Gist options
  • Select an option

  • Save eolszewski/e818fbcdd3f3e98713410dbaa6550ea5 to your computer and use it in GitHub Desktop.

Select an option

Save eolszewski/e818fbcdd3f3e98713410dbaa6550ea5 to your computer and use it in GitHub Desktop.

Revisions

  1. eolszewski created this gist Aug 22, 2018.
    39 changes: 39 additions & 0 deletions EventStore.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    pragma solidity ^0.4.19;

    import "./EventStoreLib.sol";

    contract EventStore {

    EventStoreLib.Storage store;

    address public owner;

    function () public payable { revert(); }

    constructor() public {
    owner = tx.origin;
    }

    function count() public view
    returns (uint) {
    return store.events.length;
    }

    function write(bytes32 key, bytes32 value) public {
    EventStoreLib.write(
    store,
    key,
    value
    );
    }

    function read(uint index) public view
    returns (uint, address, bytes32, bytes32 ) {
    return EventStoreLib.read(store, index);
    }

    function destroy(address target) public {
    require(msg.sender == owner);
    selfdestruct(target);
    }
    }