Giter Club home page Giter Club logo

ethbase's Introduction

Ethbase

Gitter chat

The aim of this project is to provide a mechanism for enabling smart contracts to subscribe to events emitted in other contracts. For a short description of the why and how of this project, you can refer to the about wiki page.

Events are submitted to the network by relayers. To make the process trustless, relayers provide MPT proofs that the event log they're submitting has been included in the receipts trie of a recent block (last 256 blocks).

Note: Ethbase is currently in a very early development and experimental stage, and is not suitable for production use.

Rinkeby: 0x2ccf778b371e24010b6733a377e999844bdc114a

Usage

In the given example, we have an Emitter contract, which emits Transfer(uint256) when its method is called. We want our Subscriber contract to update its state, whenever Transfer is emitted. This can be done, by subscribing to the registry, and specifying the target event and the callback method that should be executed when the event is emitted. Afterwards, any relayer, upon seeing a Transfer event, can call submitLog on Ethbase, which would in turn invoke Subscriber's specified method.

To subscribe to an event, you can create an instance of Ethbase and call subscribe in your smart contract:

ethbase = Ethbase(ethbase);
ethbase.subscribe(emitter, eventTopic, subscriber, method);
  • emitter is the address of the contract that emits the event.
  • eventTopic is the topic you're interested in, e.g. keccak256("Transfer(uint256)").
  • subscriber the contract that should be called when event is emitted, e.g. this.
  • method the method that should be called. Method must have the same signature as the event, and generated by bytes4(keccak256("METHOD_NAME(TYPE1,TYPE2)")).

Contribute

Most of the discussions are happening in the issues and pull requests, Suggestions, contributions and critisisms are more than welcome, join in.

If you want to get involved: first of all, thanks for considering to do so! Here's how you can setup your environment:

Requirements

Node is the only thing you need. After cloning the repository, install the dependencies, and build the contracts.

$ npm i
$ npx truffle compile

Tests

To run the contracts test suite:

$ npx truffle test

ethbase's People

Contributors

s1na avatar hemulin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.