Catena: SQL on a blockchain

A blockchain allows different entities share a database without having to entrust that database to a single entity. Blockchains were introduced with Bitcoin, and are finding their way into more and more applications. Technologies such as Ethereum allow anyone to create applications, or ‘smart contracts’, on top of a blockchain. The interesting thing about blockchains is that while it usually fills the role of a database, there are no blockchain implementations as of yet that actually act like a database. Catena is an attempt to fill this void: it provides an SQL database on top of a blockchain, providing all the benefits of blockchains (resiliency, distributed operation, openness) while providing a familiar interface to its users.

Catena is a distributed SQL database built on top of a blockchain. This allows organisations to reliably share consistent and trustworthy information without relying on centralized trust.

Why is this important? The most important technology for custom applications on a blockchain right now is Ethereum. Ethereum provides both the storage as well as business logic capabilities that allow for complex applications to be written on top of a blockchain. There are however several fundamental issues with Ethereum’s design that make it less attractive for actual business adoption:

  • The technology is complex and doesn’t fit well with existing enterprise technology. Smart contracts for Ethereum are written in a special programming language. In practice, the business logic in the contract is kept to a minimum, with other business logic residing in special ‘Dapps’ that interact with (and call smart contract ‘functions’ on) the chain.
  • All operations on Ethereum are paid for in ‘ether’, the network’s currency. As ether is also a asset used for speculation, your computations become exponentially expensive over time.

Catena attempts to solve both of these issues by providing a blockchain that just provides what it does best: a distributed database with access control. In Catena, users interact with the blockchain through SQL. Applications can even connect to Catena over the PostgreSQL wire protocol, which means that in most programming language, accessing a Catena database can be done in a few lines of code.

Blocks in Catena store SQL transactions that are verified and replayed by each client locally. Querying the Catena database is done locally – only mutating SQL transactions are appended to the chain. Such transactions are authenticated with a public-private keypair. A ‘grants’ system determines whether a transactions signed by a particular public key is actually allowed to execute. Catena does not provide a generic currency – instead, the grants system determines a user’s rights to append to the chain.

Some other technical details:

  • Catena stores transactions in SQL on the chain. Catena parses each SQL transaction it receives (from a user or in a block) with its own SQL parser, that is also used to determine the required privileges. When execution is allowed, transactions are translated to SQL for a backend database (currently SQLite).
  • Catena peers communicate over HTTP and WebSocket. End-users can talk to Catena over HTTP and submit queries using the PostgreSQL wire protocol (i.e. using the command line ‘psql’ command)
  • For authentication, Catena uses Ed25519 public-private keys. Like in Bitcoin, addresses are encoded and displayed using base58check-encoding.
  • The proof of work used in the current version of Catena is a simple SHA256 ‘leading zero bits’ implementation. In the future, Catena will provide different options for PoW as well as a configurable and dynamic difficulty level.

Catena is open source – try it today!

Read more: Catena on Github

Media coverage & discussion