Building full-stack dApps today

Share
  • November 16, 2018

Blockchain and Distributed Ledger Technology (DLT) have promised the internet several significant improvements:

  • Manageable transparency and governance of data
  • Bulletproof security, through trustless systems
  • Significantly decreased transaction costs

In reality, though, a significant amount of traditional “web2” technology is still needed in order to build a dApp, due to the ecosystem’s temporary lack of decentralized scalability.

    Blockchain Whitepaper 2018

    Free: Blockchain Technology Whitepaper

    If building a blockchain from scratch is beyond your current scope, the blockchain technology whitepaper is worth a look. Experts from the field share their know-how, tips and tricks, development advice, and strategy for becoming a blockchain master.

We will reference Ethereum’s smart contract platform since it captures a large majority of today’s dApp market. Ethereum provides a completely decentralized computation service, using smart contracts and a proof of work consensus protocol. It provides more transparency, better security, and [sometimes] lower transaction costs, compared to existing web2 technology. The only problem: it doesn’t scale yet.

Today’s challenges building dApps at scale:

  • Ethereum network performance is limited to ~20 transactions per second.
  • Querying Ethereum’s 90+GB blockchain can be extremely slow.
  • Real-time updates are not feasible, because transaction times are often 12+ seconds long.
  • Interacting with the blockchain requires interfacing with a trusted node, and self-hosting nodes is still an unreasonable barrier to entry for most users.
  • Lack of secure and affordable decentralized data storage.

This doesn’t sound like a very efficient tech stack yet; however, thousands of passionate teams are working night and day to improve these issues, in order to unlock the underlying value mentioned above. Researchers and developers around the world are prototyping sharding solutions, new protocols like Plasma, and off-chain solutions like Raiden Network. Being part of blockchain innovation also means granting trust that this community will scale their networks over the coming years.

Bridging web2 & web3

In the meantime, there’s no way to avoid bridging web2 technology with your dApp. Here are the primary pieces to consider when building a hybrid web2 / web3 dApp:

  • Queryable index
  • Traditional database
  • Trusted gateways
  • Blockchain event subscriber

Queryable index

Building an index service allows for performant end-user search. Searching directly on-chain is much slower and requires a fully synced Ethereum node. The most performant dApps today are storing Ethereum transaction data, events, and off-chain data references in traditional web2 search indices like Elasticsearch and Solr.

 

 

Database

A traditional database allows for performant and complex data reads. Making an atomic read call to an Ethereum smart contract can be quick; however, building complex queries that join domain models on-chain can become painfully slow, or even timeout and fail. Storing domain model data in a traditional database provides massive performance gains when rendering data in your dApp.

 

SEE ALSO: The rise of blockchain dApps

Ethereum / IPFS Gateway

Although Ethereum and IPFS aim to provide a completely decentralized and trustless system, current users usually don’t host their own Ethereum or IPFS nodes. This brings up a considerable security issue, breaking the essence of a trustless system. Some services offer a semi-centralized option for the short term. For example, the popular browser wallet, MetaMask, has relied on Infura’s Ethereum gateway to read and write to Ethereum’s mainnet. Until there are stabilized and decentralized methods of implementing this handshake, it’s not a bad idea to host your own Ethereum and IPFS nodes, in order to ensure reliability and security.

 

Blockchain event subscriber

An event subscriber listens to new transactions and events on the blockchain and saves relevant data in your search indices or database. These are relatively simple to build, especially with the addition of socket pub/sub support in web3.js and respective Ethereum node clients. A common pattern here is to store data using Solidity events, rather than contract storage variables, because it costs less “gas”, meaning it’s cheaper.

 

Final considerations

These challenges are temporary, and their respective solutions are rapidly evolving. The speed at which improvements are made is staggering, due to many of these same problems having already been solved during the web2 revolution. Scaling is the largest problem, and it will require a considerable amount of research and development to solve. In the meantime, there are countless opportunities to apply hybrid web2/web3 dApp technology to existing enterprise scale. Doing so can still bring the value of transparent governance of data, improved trust, and security, as well as transaction cost savings to all sizes of business.

The post Building full-stack dApps today appeared first on JAXenter.

Source : JAXenter