Sandcastle Brings SQL to Ethereum Smart Contracts

The latest Pre-Alpha Release of the SQL Ethereum smart contract language is available!

Consensys
ConsenSys Media
4 min readMay 17, 2019

--

This article was written by PegaSys Co-Founder, developer, and researcher, Shahan Khatchadourian, Ph.D.

Millions of SQL developers are now Ethereum smart contract developers.

As someone with a passion for bridging database and blockchain technologies, I’ve spent a lot of time thinking about blockchains as different forms of databases. It’s still the case that a blockchain is not a database, yet. However, Sandcastle, an Ethereum SQL smart contract language, helps bridge that divide.

Where to Find The Sandcastle Pre-Alpha

A Sandcastle pre-alpha web service that translates SQL into Solidity, and which works on all existing clients (i.e., no changes are needed), is now available as a Remix plugin.

What Are The Benefits of Sandcastle?

Sandcastle improves Ethereum’s data management capabilities by provisioning an on-chain relational database that supports tables, (sub-)queries, aggregation, updates, triggers, and indexes. Smart contracts based on relational semantics can be automatically optimized for transaction cost, performance, scalability, and security across blockchains and databases.

Sandcastle operates by translating each table into a smart contract that contains rows of data structured according to the table’s schema. Queries, updates, triggers, and transactions are smart contract methods that execute against these tables. Our tool hides the complexity of joining multiple tables, computing aggregations, using indexes whenever possible, and using Solidity data structures effectively. The architecture diagram below shows that Sandcastle fits into existing development processes because the generated code can be integrated with pre-existing code and compiled using the standard solc-based toolchain.

Why Did PegaSys Build Sandcastle?

Enterprises need to manage and understand complex data in order to make informed business decisions. But committing to that effort will first require strategies to mitigate the associated costs and risks. One way to reduce risk is to improve blockchain’s data management capabilities. One way to reduce costs is to rely on the expertise of the millions of existing SQL developers by turning them into Ethereum smart contract developers.

Enterprises will benefit from the (re-)use of SQL as a way to preserve application logic across private and public Ethereum blockchains and databases, while optimizing for each. For example, Sandcastle’s optimizer will be able to take SQL code and generate smart contracts that minimize transaction costs in public chains, and can also generate smart contracts that perform identical application logic while maximizing performance in private chains. Developers won’t have to spend any time hand-coding brittle optimizations that limit agility and innovation. One of the most promising features is the ability to integrate existing enterprise data to model and simulate transactions and processes. We will share more about these exciting features soon.

Want to join the team? PegaSys is hiring! To keep up to date on PegaSys’ progress, check out our Github and follow us on Twitter. Check out our list of open roles.

Sandcastle is one of several steps we’re taking to help advance blockchain data management. If you’re an enterprise that is familiar with databases, focused on building Ethereum applications (i.e., not necessarily low-level), and willing to experiment with Sandcastle, do get in touch. This is an opportunity to give your input to our work blending database and blockchain paradigms.

Disclaimer. The views, information, and opinions expressed are solely those by the author above do not necessarily represent the views of Consensys AG. They are meant for informational purposes only, are not intended to serve as a recommendation or investment advice to buy or sell any securities, cryptoassets, or other financial products.

Originally published at https://pegasys.tech on May 17, 2019.

--

--

Consensys
ConsenSys Media

A complete suite of products to create and participate in web3.