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.
Let's start with the end goal and work backwards from there: A BCH full stack developer, with the skills that businesses are willing to pay good money for, can build a wallet application or some other application that talks directly to the BCH blockchain. It can reliably receive and send transactions. They are able to run and maintain the infrastructure required to support that application.
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.
- Badger Wallet is really two wallet apps. One is for smart phones and the other is for web browsers. But they function the same. This is one of the leading wallets for working with SLP tokens.
- 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.
- Honest is a blogging platform similar to Medium. After writing an article, authors can embed the article into the BCH blockchain, so that it can never be deleted or censored.
- Satoshi Dice is a very simple gambling game that lets you bet with BCH. Because is uses the BCH blockchain, all bets and payouts are publicly transparent and the game is provably fair.
This wide range of applications all use the same common back end infrastructure.
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.
- REST API - A REST API web server provides an interface for all modern programming languages to communicate inderectly 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.
There are very few free or paid REST API services for working with BCH. The industry needs more, and you could profit by providing these resources. This article will outline the steps you can take to run your own cloud infrastructure, to earn BCH as illustrated in this video:
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. It's also possible to purchase a hard-drive with a pre-synced full node.
There are several full node implementations. Here are a few:
- ABC has the majority of market share. Its 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.
This article only focuses on the ABC implementation of Bitcoin Cash. I maintain a Docker container for running a 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:
- rest.bitcoin.com is an extension of developer.bitcoin.com.
I have not tried out these other REST APIs, but they look interesting:
- Interfacing with the OpenBazaar Indexer
- Works with SLP tokens natively (no external libraries).
- Includes endpoints for Blockbook and Bitcore indexers.
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 bch-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. And that book is free and one of the best resources.
A more experimental version of bch-cli-wallet is slp-cli-wallet. This fork has additional functionality to work with SLP tokens. Be sure to check the GitHub Issues for known bugs though, as it's not as stable as bch-cli-wallet.
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 over a year. Here is the advice I have to give to aspiring developers who want to set up their own minimum viable infrastructure:
- 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's not as responsive as the other indexers, but 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, I sell a hard drive that contains the fully synced databases containing the last eleven years of blockchain data. The files on that hard drive are intended to work with the above Docker containers. It should reduce the time syncing to a couple hours.
Alternatively, I've set up a server that syndicated the above databases over IPFS and BitTorrent. You can access the information to download the files here.
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:
- BITBOX Devs is a public channel for asking questions around rest.bitcoin.com, BITBOX SDK, and SLP SDK.
- Permissionless Software Foundation is a channel for discussing bch-js, bch-api, slp-cli-wallet, and other software sponsored by the Permissionless Software Foundation
- 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!