Git Product home page Git Product logo

zap-web3's Introduction

ZapWeb3 ⚡️

It provides a solution for automating repetitive tasks. Users can create custom flows will automatically be triggered by specific events emitted by smart contracts, which in turn will lead to a series of predefined actions being executed.

Building Blocks: How i Built it 📦 💻

TechStack

Turborepo, NextJS, RabbitMQ, ExpressJs, TypeScript, MySQL

⏭️

In total, I have three applications. I'll go through two of the main ones: Events Service and Action Service.

The Events Service acts as the service that registers the contract events. When a user makes a request to my API, which acts as the gateway, it publishes the message to the RabbitMQ queue to register the smartcontract event. The same process applies when disabling the event listener.This service is also responsible for calling the action service as soon as the event is triggered 📣.

Next, the Action Service is responsible for executing the flow, which consists of the actions to be performed, such as posting a Slack message 💌 or Triggering a webhook 🪝. To enable the execution of these actions, I decided to implement a workflow engine. Below is the pseudocode for the minimalist workflow engine that I implemente:

Psedocode

This is just a high-level overview of what I have implemented. You can handle scenarios where the flow should completely fail or not in case one action encounters an error. The "emit" part in the pseudocode is where I have made use of Node.js event emitter.

WorkflowEngine:
    flows = []

    addFlow(flow):
        flows.push(flow)

    startEngine():
        emit "workFlowEngineStarted"
        for each flow in flows:
            executeFlow(flow)

    executeFlow(flow):
        emit "flowStarted" for flow
        currentIndex = 0
        retries = 0
        previousActionResult = null

        executeNextAction():
            if currentIndex >= flow.actions.length:
                emit "flowCompleted" for flow
                return

            action = flow.actions[currentIndex]
            emit "actionStarted" for flow and action

            action.execute(previousActionResult):
                emit "actionCompleted" for flow, action, and result
                currentIndex++
                previousActionResult = result
                executeNextAction()
            catch error:
                // Handle errors here 

Demo ⚡️

ZapWeb3Demo.mp4

zap-web3's People

Contributors

hussainzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sandeepv2

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.