Kwil Concepts
Because Kwil database networks are sovereign blockchains, there are a few concepts that are unique or borrowed from other blockchain platforms. These concepts are transversal across Kwil (frontends, SDKs, Nodes, etc.).
Accounts
Accounts are public / private keypairs that represent a single user or entity on a Kwil Network. Accounts are used to deploy databases and execute CRUD operations.
Each account has an identifier (either the hex-encoded public key, or address), nonce, and balance.
Accounts are identified by public keys. Natively, Kwil supports Secp256k1 keys (used in EVM) and ED25519 keys (used in Solana, NEAR, etc).
Databases
In Kwil, databases refer to relational database schemas on a Kwil Network. The Kwil SQL engine is based on Postgres with modifications to support deterministic execution and consensus.
Kuneiform
Kuneiform is a simple syntax language for defining a database on Kwil. You can think of Kuneiform as a smart contract language (e.g. Solidity), but for relational databases.
In a Kuneiform file, you can define:
- Tables - The structure of the database.
- Procedures - SQL Queries and business logic that can be executed on the database.
- Actions - CRUD Operations that can be executed on the database, and call extensions.
- Extensions - Import additional logic that can be executed on the database.
- Foreign Procedures: Define an interface for interacting with procedures in another database.
Database Identifiers
Database identifiers (DBIDs) are unique identifiers for a database on a Kwil Network. DBIDs are generated from database name and database owner's public key. A DBID is a SHA224 hash of the database owner's account public key and database name.
Transactions
Transactions are database deployments, database drops, and state changing (create, update, delete) procedures/actions that are executed on a database. Transactions are signed by an account and are propagated to the Kwil Network. Transactions are executed deterministically on each node in the network and are validated by the nodes.
View Procedures/Actions
View procedures/actions are the primary way of reading data from a database. View procedures/actions are called from a single node and may or may not require signature. The advantage of view procedures/actions is that they can be executed without the need to wait for consensus.
Kwil Network
A Kwil Network is a sovereign blockchain that is used to deploy databases and execute CRUD operations. Kwil Networks are composed of one or more Kwil Nodes. A project may have its own Kwil Network, or multiple projects may share a Kwil Network.
Kwil Node
Kwil Nodes run the Kwil Daemon and are the infrastructure that power Kwil Networks. Kwil Nodes are responsible for:
- Storing the state of the Kwil Network
- Executing transactions
- Validating transactions
- Propagating transactions to other nodes
- Maintaining consensus
Each node has a public / private ED25519 keypair that is used to sign transactions and blocks. Note that the Node keypair is only for validating the blockchain, and is different from the account keypair.
Extensions
Extensions are modules that customize the behavior of a Kwil Network. Extensions can be used to customize the cyrptographic signature used for verifying accounts, import libraries into Kuneiform, and implement built-in network oracles and governance rules. Extensions are written in Go and compiled with the Kwild binary.