How to become a BCH Full Stack Developer
This is a guide to becoming a Bitcoin Cash (BCH) full stack developer. It's a deep rabbit hole and a long journey to mastering the full stack of BCH software, but the reward is making modern web and mobile apps that speak directly to the blockchain. But first, lets start with the most basic question: What is a BCH full stack developer? What does that term even mean?
What is a BCH full stack developer?
Let's start with a couple definitions:
Full Stack: Developers will typically specialize in front end development: phone apps, web apps, or other things with a user interface (UI). Or back end development: web servers, desktop applications, anything not involving a user interface. A full stack developer is one who is proficient at both.
Dipping your toes in the water
Before digging into the nitty-gritty back end infrastructure, it's often encouraging to 'skip ahead' to the end and show yourself why you're about to work so hard to learn all that infrastructure. Here are some examples of popular front end applications. Each of these apps use back end infrastructure that this article will show you how to set up.
Memo is a clone of Twitter, but uses the BCH blockchain. Because its based on the blockchain, there can be no deplatforming or censorship of any kind. Memo also includes a decentralized exchange for selling SLP tokens.
read.cash is a blogging platform similar to Medium. The site implements a BCH wallet and 'micro-tipping'. You can tip an auther as little at $0.05 to show your appriciation for their work. Comments are upvoted based on these micro tips, which leads to really healthy discussions about the content.
The Full BCH Stack
The diagram below illustrates the stack of software required to build applications like the ones above. Those applications all fit into the top-most layer of the stack.
Here is a description of each layer, starting at the bottom and working up to the top:
Full Node - A full node is the most fundamental piece of software in Bitcoin. This is a 'non-pruned' or 'archival' node that contains a full copy of the blockchain.
Indexers - Indexers are like small search engines. They communicate with the full node and crawl the blockchain data to create databases that contain additional metadata that is not directly accessible from the full node. This metadata includes things like SLP tokens, and posts on Memo.cash.
REST API - A REST API web server provides an interface for all modern programming languages to communicate indirectly with the indexers and full node. This layer provides a common interface for modern software (like web and mobile apps) to speak to the blockchain.
Applications - Finally, the application layer is where the magic happens. This is the business logic that makes one app different from another. This is the user interface that end-users get to interact with. This is the layer where front end developers play. The examples listed in the last section all fit into this layer.
This entire software stack can be run on a modern computer with 16-32 GB of RAM, 1-2 TB of hard drive space, and a decent internet connection.I'll explore each layer in more detail in the sections below. I'll also link to Docker containers for running each layer of the stack.
Skipping the back end
To help front end developers get started quickly, and to remove the burden of hosting your own back end infrastructure, there are a growing list of cloud service providers. This provides convenience at a price.
Note: Trusting a service provider to handle the back end infrastructure for you is convenient, but if their servers go down, your app goes down with them. And unless you run your own fall-back infrastructure, you have no recourse but to simply wait until they get back up and running. This is known as platform risk. The only way to eliminate platform risk is to run your own infrastructure.
Here are a few of the cloud-based REST APIs for interacting with the BCH network:
bloq.cloud and Block Cypher are a pay-to-play REST APIs with similar access as the above options, but they have very different structures to their REST API. While it's easy to switch between Bitcoin.com tools and FullStack.cash tools (because they are forks of the same code base), there is much more work involved with switching to these other platforms.
Running a Full Node
The full node is the most fundamental piece of software. To run a full node, you'll need enough hard drive space to store the blockchain. This is currently under 200GB, but it's always growing. You'll also need at least 2 GB of RAM. Syncing a full node can take anywhere from 2 days to 2 weeks, depending on your hardware and internet connection.
There are several full node implementations. Here are a few:
ABC has the majority of market share. It's the implementation that started the BCH fork, and is the most widely used by exchanges and miners.
BU is the second most popular Bitcoin Cash implementation.
BCHD is a rapidly growing, developer-friendly implementation written in Go.
Flowee the Hub is a one of the newest implementations on the scene.
Bitcoin Verde is another full node implementation.
This article only focuses on the ABC implementation of Bitcoin Cash. I maintain a Docker container for running this full node. Installation instructions can be found in the GitHub repository for docker-abc.
As mentioned at the beginning of this article, indexers are like little search engines that crawl the blockchain and stitch together metadata that is not directly available from the full node. The two most important features that an indexer provides for wallet apps and other modern applications is:
- BCH balance lookup by address
- UTXO lookup by address
A couple widely used, open source indexers are:
Those links will take you to Docker containers that I maintain for both indexers.
A few up-and-coming indexers include:
- BCHD has indexing capabilities via its startup options and its gRPC interface.
- Flowee Indexer is a new, experimental indexer.
The Simple Ledger Protocol uses an indexer to validate token transactions. SLP tokens are one of the newest, most popular protocols that ride on top of Bitcoin Cash. Each SLP token is a 'colored' UTXO. Token transactions are tracked using OP_RETURN data in transactions. The indexer follows the trail of transactions to track token balances.
The REST API is the communication interface that lets modern web and mobile apps talk to the blockchain. It's a lightweight webserver that wraps the indexers and full node in a REST API. This allows high level applications to talk to low-level interfaces.
Some of the REST API services that exist:
I have not tried out these other REST APIs, but they look interesting:
- Interface with the OpenBazaar Indexer
- Works with SLP tokens natively (no external libraries).
- Includes endpoints for Blockbook and Bitcore indexers.
- Support for BCHD comming soon!
Finally! We're at the application layer! Yay!
While bitbox-sdk, slp-sdk, and bch-js provide important functionality, most application developers are disappointed in how much bitcoin-specific knowledge is required to interact with them. That's why I created slp-cli-wallet. It's a command-line interface (CLI) app, but it's also an npm library that can easily be included into any other application. It provides high level functions like
send-bch. It reduces the amount of bitcoin-specific knowledge required to create applications.
Speaking of required knowledge, all developers in this space should read and frequently refer to Mastering Bitcoin Cash. It'll be hard to go far in this space without familiarizing yourself with basic Bitcoin concepts. The book is free and one of the best resources.
Also, there is Badger SDK. This provides React components and other code examples for interacting with Badger Wallet. If you want to replace Paypal buttons with BCH buttons, this is the fastest way to do it.
Minimum Viable Infrastructure
There is a concept in the startup world of a minimum viable product or MVP. There are so many options of full nodes, indexers, and libraries that its easy to waste a lot of time on a less-than-optimal solution. I've been working full-time on BCH infrastructure for two years. Here is the advice I have to give to aspiring developers who want to set up their own minimum viable infrastructure, it's based on the downloadable databases here.
Use this ABC full node Docker container. It's the most popular full node implementation, and it's hard to go wrong with that choice.
Use Blockbook for your indexer. It has the smallest database and has shown to be the most reliable. This Docker container allows you to run your own BCH version locally.
If you plan to dip your feet into the world of SLP tokens, then you'll want to run this Docker container. It contains everything needed to interact with them.
It will take weeks to sync the full node and indexers on a home computer. To shorten this time, you can download pre-synced databases that contain the last eleven years of blockchain data. Those files are intended to work with the above Docker containers. It should reduce the time syncing to a couple hours.
A final tip: Avoid testnet. It's traditional to develop apps using the testnet so that you don't waste real money. But the reality is that testnet is often too flaky to use, for a number of reasons. At the same time, it's possible to send 1000 sat (0.00001 BCH, a fraction of a penny) transactions on mainnet, with a mining fee of 1 sat/byte, while maintaining a high confidence that the transaction will be included in the next block. That makes a compelling argument to use mainnet for app testing instead of testnet. Most developers I know, including myself, take this approach.
The Bitcoin Cash space is a rapidly moving target. The core concepts in this article won't change much, but the tools, implementations, and libraries are in a constant state of flux. A big part of being a successful full stack developer is injecting yourself into the community, so that you can ride the flow of ever-changing information. Most of the community discourse takes place on Telegram:
Simpleledger is the place to explore and ask questions around SLP tokens.
Fountainhead is a public channel run by a group of experienced BCH developers.
The above channels are a great place to get introduced to the Bitcoin Cash developer community. There are many other private channels (requiring an invite) where the real development discussion happens. Asking sincere questions and showing off your work in the channels above are the best way to find access to those channels.
A lot of discussion and sharing also happens on Twitter. You can follow me @christroutner. I follow and interact with many BCH full stack developers on Twitter, and you can too.
I can't wait to see what you build!