Redux is the most popular state management library for JavaScript. Its common use case is to keep large React web applications organized, but it’s also used with other front-end libraries and even on the back-end. At BTL, we are huge fans of Redux.
A blockchain is a cryptographically secured distributed append-only datastore which persists data in a linked list of blocks. Most have heard of blockchains as the underlying technology for crypto currencies, but its incorruptible nature makes it a useful datastore in environments where hardware can become faulty or bad actors have an interest in changing the data for their own benefit.
A second generation blockchain such as Ethereum allows you to run custom programs (“smart contracts”) on the blockchain to solve much wider problems than just dealing with simple (financial) transactions, which is what first generation blockchains are limited to. An interesting requirement for smart contracts is that they need to be reproducible so that old blocks can be verified, i.e. the data stored in a block is the correct result of applying all transactions from that block against the data from the previous block.
We can easily draw a diagram to represent a developer’s perspective on blockchains that is very similar to Redux. Smart contracts and the consensus mechanism are taking transactions and process them to change the data.
Redux:
Blockchain:
Now imagine a Redux implementation where the Store is really a blockchain store. Or, imagine a second generation blockchain that is as developer-friendly as Redux. Once you have that visualized, you actually have a pretty accurate picture of Interbit, a new private and scalable blockchain we are building at BTL.
Interbit:
The term Covenant might be unexpected. We chose it because “smart contract” is really a misnomer as it’s neither “smart” nor a “contract”. Venkatesh Rao explains the difference in Blockchains Never Forget.
More important for Redux developers is to know that the covenant includes plain Redux reducers, i.e. pure functions that take an action and the current state, and then return the new state. Pure reducers are a perfect fit for covenants because they provide the required reproducibility. The rest of Interbit should be just as familiar. Actions in Interbit are ordinary Redux actions in that they’re a plain object with a type and a payload. And the Interbit store has the same interface as the Redux store so we can subscribe to it, dispatch actions into it, and get the current state using getState()
. The only notable difference is that dispatch(action)
returns a promise that resolves once the action has been reduced and added to a block.
You don’t really need to know anything about the Consensus part because Interbit is dealing with that automatically. It is however an important part of the diagram because if the blockchain network does not reach consensus on an action that was dispatched into the store, the action and the reducer’s result for that action won’t be added to the chain, i.e. they are not persisted in a block.
We are getting very close to releasing a first version of Interbit for you to try out. You might be familiar with the Todo List example. You’ll be able to use the same code; essentially just swap out Redux for Interbit, and have the Todo List up and running on your own blockchain. What that means is that every JavaScript developer who’s used Redux before will feel right at home with Interbit and easily integrate it with their existing applications without needing prior blockchain experience.
We can’t wait to show you Interbit. It is a 100% JavaScript project that runs on Node.js and in the browser. Sign up on interbit.io to be notified when we release. And watch out for future postings where we explain why Interbit is the next generation blockchain, and show how to add oracles to your covenants (spoiler alert: oracles are side effects that run with redux-saga).
Author: Christian Pekeler
Christian Pekeler has two decades of experience crafting software for various industries. He is leading BTL’s engineering team that is creating the core technology powering Interbit.