Launch kwil
Blog/
Introducing: Kwil Extensions
Product
August 7, 2024

Introducing: Kwil Extensions

Luke Lamey
Share:

Today, we are excited to introduce a new paradigm for implementing custom logic and functionality in a decentralized database: Kwil Extensions. Extensions vastly expand the features that can be built for your decentralized application, allowing developers to connect to any blockchain, implement any logic, and dramatically improve dApp functionality at the database level.

As a plug-and-play solution, extensions allow developers to easily define and reuse arbitrary logic to be implemented in their database. Databases can support an arbitrary number of extensions, and developers are free to reuse some of their favorite extensions built and released by other teams. In the future, we envision an extension marketplace where teams can openly exchange their extensions and compose on each other’s work.

Connect to any chain. Execute any logic. Welcome to the era of modular database software.

What are Extensions?

Extensions are stateless applications that connect to and run in parallel to your Kwil database. They allow developers to inject custom functions directly into database queries, allowing the creation of complex logic that cannot be represented in just SQL. With an extension, you can automatically inject data from external sources into your database, push data from your database to external targets (e.g., a smart contract), and implement fine-grained access control and verification mechanisms.

Extensions are run as containerized applications, written in any language, and imported into your Kwil database. When executing queries on the database, action logic is simultaneously executed. The average extension requires only ~100 lines of code.

Introducing Kwil Extensions (2).png

 

What can I build with Extensions?

The short answer: just about anything.

The long answer: Extensions allow you to connect to any external data source and implement logic around that data. Some extensions we already see being built today include:

  • Token Gating: Developers can use extensions to restrict access to data based on some on-chain asset. Users can be required to hold tokens, deposit funds, own an NFT, etc. to access the database.
  • Token Incentives: Extensions can automatically distribute token rewards to users for creating data. This functionality allows projects to build protocols around incentives for sharing composable data (e.g., IOT data, inflation data, etc.) and receive automatic rewards for doing so.
  • Access Control: Extensions can connect to external authentication sources to govern access to data. Extensions can check a user's credentials before executing a query, enabling stronger privacy and authentication for decentralized data.
  • Stateless Functions: Developers can build stateless functions to be called from within a Kwil database. This is useful for creating intermediary logic to manipulate data sent to the database before storage (e.g., executing cryptographic primitives).

How to get started with Extensions?

Extensions must be embedded directly in a deployed Kwil network. In order to deploy a custom extension, you must run a local Kwil node with an extension server. Kwil also provides managed hosting for Kwil nodes with an extension server to run in production (reach out to help@kwil.com to learn more).

Kwil offers Golang and TypeScript/JavaScript SDKs for creating extensions. Information on how to use each package and code samples are found in the documentation. Once your extension is ready for deployment, you can plug it into the Extension Deployment Script to run your extension on a local Kwil node.

More information on containerizing your extension and deploying it with a Kwil node is found here.

Introducing Kwil Extensions.png

Next Steps

From here, we are excited to see what functionality developers implement on their databases with extensions. We are actively collaborating with our partners on extensions to connect Kwil to other blockchains, making Kwil the first truly cross-chain decentralized database platform.

Do you have an idea for an extension you would like to collaborate on? Reach out to us on Discord or send us a note at help@kwil.com.

We can’t wait to see what you #BuildWithKwil.