Design pattern of developing Ethereum applications on EthVigil API gateway

Anomit Ghosh
Jun 11, 2020 · 4 min read

“Confirmation-driven” development

Building apps on a decentralized blockchain platform like Ethereum requires integration of different moving parts, the most important being that operations that change data(aka state) on the chain are “confirmed” only after the inclusion of a transaction in a block and the same being agreed upon by participating peers in a consensus protocol.

(a) Client-server paradigm, centralized databases and guaranteed confirmations

Let us take the example of working with a Pet Store on REST APIs, in the classic server-client paradigm.

Request to server: POST https://petstore.swagger.io/v2/pet
Response from server: 200 OK

Here the app receives a HTTP POST request and returns back a confirmation with the HTTP status code set to 200. The UI usually reflects the same back to the user within a few seconds of delay. Behind the scenes, the backend server, storage, database and other services that make up the PetStore App coordinate on a HTTP POST request to create a new entry against a pet.

In short, the database is centralized (belongs to PetStoreCo.) and operations on it can be confirmed without much delay and with no consensus involved.

(b) Peer-to-peer paradigm, decentralized and distributed databases and confirmations-on-consensus

When it comes to a decentralized database, and the blockchain protocol encapsulating it, there is no one central server or endpoint that can definitively confirm the append of data and an application should not update its UI or backend state unless a consensus has been reached among peers that participate in the network and propose new blocks.

This new paradigm of of waiting for consensus and confirmation of write operations, requires adaptation among application developers new to blockchain to move to an asynchronous callback, event-driven architecture.

If you wish to delve deeper into the life-cycle of a transaction on Ethereum, go through the following article on our blog.

Asynchronous, Event-driven application architecture powered by EthVigil

Sequence diagram for a typical workflow to build applications on top of EthVigil API gateway that runs on the Ethereum blockchain

So far we have released projects and code snippets that demonstrate the several ways you can compose such an architecture across different stacks and platforms — whether it be a command line application or a full-fledged web application. Go ahead and check out the implementation details to see the above proposed architecture in action.

Atlas Library System: A blockchain based hassle-free library rental system built around the concept of ERC20 tokens powered by EthVigil API. This was built by Aditya Vijaykumar (Twitter: @AdityaVijaykum4 ), one of our remote bootcamp graduates for the EthGlobal Hackmoney 2020 hackathon.

💻 Source code| 📒 Hackmoney entry| 📲 Application webpage

TODOApp implemented as part of our in-house developer meetups.

💻 Source code| 📒 Explainer Blog Posts. Part1. Part2.

Adabdha: a web application for generating secure, auditable and verifiable movement passes. Restricted authorized vehicle passes issued in a centralized, opaque manner during COVID-19 lockdowns was the motivation behind us proposing a decentralized protocol for the same.

💻 Source code| 📒 White Paper | 📲 Application webpage

Working with ERC20 token contract

💻 Source code| 📒 Documentation

EIP-712 compliant signing of messages

💻 Source code| 📒 Documentation

Reach out to us

  • Join our discord server. This is where we can be found most of the time and is the best place for technical discussions. Want to discuss blockchain protocols? Facing issues or doubts about integrating our APIs into a blockchain app? Shoot us a message!
  • You can raise Issues on our github repos if you face trouble using our CLI or following any of the API usage examples.
  • Join our twitter to get updates on our latest code releases, development guides, upcoming meetups and webinars.
  • Any other questions? Email us at hello@blockvigil.com
  • Don’t forget to sign up for your EthVigil Beta account at https://beta.ethvigil.com (Docs: ethvigil.com/docs)

If you are not aware yet of what EthVigil aims to achieve for Ethereum, we recommend reading our very first introductory article.

TL:DR; We bring you HTTP APIs to interact with the Ethereum chain without worrying about

  • synchronizing with the chain and other infrastructural concerns
  • gas estimation for transactions and transaction fees
  • nonce correction
  • chain reorganization

…and quite a few other protocol dependent primitives. Visit our publication page on Medium to read more articles.

BlockVigil

The API Gateway for Blockchain

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store