shruggr / Bitflow

7 stars 2 forks source link

Bitflow

Bitcoin Dynamic Workflow Engine

Explanation

Rather than solving a single onboarding problem, we decided to focus on building a platform which allows for many different solutions to be built.

Bitflow is a task-based workflow engine which allows custom workflows to be easily built and run on top of Bitcoin SV with every action immutably.

There are endless possibilities for workflows: a production line, a supply chain, mystery shoppers, a list of household chores or even an Easter egg hunt.

Onboarding Goals

Bitflow allows developers (and with UI refinements, administrative users with limited technical expertise) to build powerful task-based workflows, where progress and payments are recorded to Bitcoin, without needing to understand Bitcoin.

Bitflow allows users to earn Bitcoin for performing tasks without needing any fiat or cryptocurrency.

Bitflow workflows can collect payments and make payouts of any amount of Bitcoin at any step of the workflow.

Features

Artifacts

Technology

Details

Everything starts by defining a Workflow. A Workflow is comprised of a series of Stages where a Task is assigned to a user to collect data which fits a defined Schema. The data is validated and processed by running a Script which updates the State of running workflow instance.

Workflow

A Workflow is created by submitting a WORKFLOW transaction containing its JSON definition. In it's current implementation, users need to build Workflow definition JSON manually and upload through the Workflow Management page, but a full implementation would include a UI for building definitions.

See Protobuf Schemas and Bitcoin Protocols for details.

Stage

A Workflow is comprised of a series of Stages. Each Stage of a Workflow defines the Schema of the data to be submitted; the Script which is responsible for validating the data; and a Handler which instructs how to handle submission. Additionally a Stage can require Bitcoin to be paid with data submission.

The current implimentation is limited to series processing, where completing one Stage will initialize the next, but this can be improved to allow logical forks and parallel processing.

Handler

A Handler defines how the Workflow should react to events in a Stage (only Completion event is implemented). This includes defining what Script will process the event data, the next Stage of the workflow, who to assign the next Stage, and what funds to pay the assignee.

For simplicity, the assignee is implemented as a hard-coded Bitcoin address, but it is envisioned that the assignee could be unassigned and "claimable", or a multi-sig "group".

Scripts

A Script is javascript function whose source code is stored in a SCRIPT transaction. The function receives a Context object as input and returns a status code as output. The Context object includes the cumulative workflow State which can be updated within the function.

State

A Workflow is a definition of a process, A State is an instance of the Workflow. State is not written to Bitcoin, but is a stored representation of of the cumulative progress of a series of Bitcoin transactions.

A State is created by submitting a REQUEST transaction which provides a pointer to a Workflow and the data required by the Schema of the first Stage of that Workflow.

Process Flow

  1. Customer submits REQUEST transaction data to server
  2. Server validates submitted data against Workflow and broadcasts if valid
  3. Bot reacts to transaction by processing workflow logic and submitting ASSIGN transaction and appropriate payments and a micropayment to facilitate flow control and allow assignee to respond without charge.
  4. Task Wallet shows assignee open task
  5. Asignee performs task and sends SUBMIT transaction to server with micropayment (5) as input.
  6. Repeat steps 2-5 until workflow complete

Photo Capture Use-case

We've chosen to focus on the use cases of Photo Capture to showcase Bitflow.

An online retailer needs curated photographs of their products. Influencers are sent products and receive BSV in exchange for taking pictures with the products. These pictures need to be reviewed and later made available on the company's online catalog.

The roles required are available in the provided Android APK. Example scripts and workflow definitions are provided and are running on mainnet Bitcoin SV.

Workflow

There are 3 distint role for this Workflow:

The Admin creates a workflow that requests:

Customer request a new Photo

The Photographer uses Bitflow's task management mobile app where a wallet address is generated, and he/she takes a photograph of the product. That transaction is submitted so a Reviewer can review the photo and details at a later time. It is not necessary for the Photographer to have funds on his address for the workflow to work.

When the Reviewer validates the photo, signs and broadcasts his transaction - potentially unbeknown to him since he may be a bitcoin layman - the Photographer receives the payout.

The workflow admin specifies the Photographer's payout when he first creates the workflow - this can be an administrative working on this online retailer company. The workflow admin is using blockchain technology without getting nitty gritty with its technical aspects or even any specific technical knowledge.

The Photographer is happy to receive his dividends in BSV.