Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ This repository contains examples and guides for how to interact with the Space

## Tutorials

- [Hello World Tutorial](./hello_world_tutorial/HELLO_WORLD_TUTORIAL.md)
- [Hello World Tutorial](./tutorials/hello_world_tutorial/HELLO_WORLD_TUTORIAL.md)
- [Community Tables Tutorial](./tutorials/community_tutorial/COMMUNITY_TABLE_TUTORIAL.md)
- [Public Tables Tutorial](./tutorials/public_tutorial/PUBLIC_PERMISSIONLESS_TUTORIAL.md)

## How-To Guides

- [How to convert between address formats](./how_to/HOW_TO_CONVERT_BETWEEN_ADDRESS_FORMATS.md)
- [How To fund a wallet with Dreamspace Pay](./how_to/HOW_TO_FUND_A_WALLET_WITH_DSPAY.md)

## Documentation
- [Tables Overview](./tables/OVERVIEW.md)
- [PublicPermissionless Tables](./tables/PUBLIC_TABLES.md)
- [Community Tables](./tables/COMMUNITY_TABLES.md)
50 changes: 50 additions & 0 deletions tables/COMMUNITY_TABLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Community Tables

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be in a explanation directory, if we're doing the 4 types of documentation in different directories


Community tables are user-owned tables with **controlled access**. Only the table creator and users who have been granted explicit permission can insert data into these tables, making them ideal for private data storage and scenarios where you need to control who can write to your tables.

## When to use Community Tables

- Private application data
- User management systems
- Controlled datasets
- Internal business data
- Scenarios where you need permission-based access control
- Multi-user applications with role-based data submission

# Example Use Case - User Management System

In this example we'll discuss a generic user management system built on Community tables that stores basic membership information. Only authorized submitters can insert or modify the user data. To create the system, we will create a namespace and a table, then we'll show how authorized submitters would add user records.

In this example we'll create the statements as if we are using the wallet address `0xABC8d709C80262965344f5240Ad123f5cBE51123`

So our namespace will be

`MYAPP_ABC8d709C80262965344f5240Ad123f5cBE51123`

And we'll use the following statements:

```sql
CREATE SCHEMA IF NOT EXISTS MYAPP_ABC8d709C80262965344f5240Ad123f5cBE51123;
CREATE TABLE IF NOT EXISTS MYAPP_ABC8d709C80262965344f5240Ad123f5cBE51123.USERS (
USER_ID BIGINT NOT NULL,
USERNAME VARCHAR NOT NULL,
EMAIL VARCHAR NOT NULL,
CREATED_AT BIGINT NOT NULL,
PRIMARY_KEY(USER_ID)
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda getting into "guide" territory, I think. I wonder if it would be best if this page was more of a compare/contrast of BOTH community tables, and public tables, with links to their respective tutorials instead of examples. Then the tutorials, in their brief explanation of their respective table types, could link back here as a "see this page to learn about other table types" or w/e

```
Which will result in a table like this:

| `USER_ID` (`BIGINT`) | `USERNAME` (`VARCHAR`) | `EMAIL` (`VARCHAR`) | `CREATED_AT` (`BIGINT`) |
| -------------------- | ---------------------- | ------------------- | ----------------------- |
| 1 | alice | alice@example.com | 1700000000 |
| 2 | bob | bob@example.com | 1700000100 |
| 3 | charlie | charlie@example.com | 1700000200 |

It's worth noting here that the table schema only includes the columns you define. **Unlike PublicPermissionless tables, Community tables do NOT automatically add a `META_SUBMITTER` column.**

## Granting Insert Permissions

By default, only the table creator can insert data. To allow other addresses to insert data, you must explicitly grant them permission using the `permissions.addProxyPermission()` transaction with the `IndexingPallet.SubmitDataForPrivilegedQuorum` permission.

Scripts, examples, and a walkthrough for creating namespaces, tables, and permissioning users can be found in the [Community Tables Tutorial](../tutorials/community_tutorial/COMMUNITY_TABLE_TUTORIAL.md)
47 changes: 47 additions & 0 deletions tables/OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Tables on Space and Time

## Overview

Space and Time (SXT Chain) is the first trustless database for the EVM, enabling smart contracts to interact with historical, cross-chain, or offchain data as if it were natively accessible onchain. Space and Time (SXT Chain) is optimized for:

* High-throughput data ingestion from blockchains, consumer apps, and enterprise sources
* Verifiable query execution over large datasets (millions of rows)
* Fast ZK proof generation and EVM-compatible proof verification with minimal gas

## Using Tables

SXT Chain is a permissionless L1 blockchain that acts as a decentralized database and enables developers to define, own, and maintain tamperproof tables using standard SQL DDL. These tables form the foundation of Space and Time’s verifiable data model, allowing structured data to be inserted, queried, and cryptographically proven at scale.

Creating a table on SXT Chain is similar to defining a schema in any relational database, but with added guarantees of verifiability and decentralized consensus. Developers submit to SXT Chain an ECDSA or ED25519-signed Substrate transaction containing CREATE TABLE SQL syntax to define table structure, including column types, and constraints.

Once created, the table is:

Assigned a unique table ID
Associated with an initial table owner (the signer of the DDL transaction)
Registered in the SXT Chain under consensus
Bound to a cryptographic commitment representing the table’s state (initially empty)
Comment on lines +19 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like github's markdown renderer recognizes this as a code block? Somehow?

It'd probably be fine to just use a numbered list or bullets instead though


All inserts, updates, and deletions from that point forward are tracked by cryptographic commitments stored onchain, allowing for ZK-proven query execution and verifiable data integrity.

When creating a SXT Chain table, there are several types to choose from depending on the application and access required:

Public/Permissionless Tables: Any user can submit data (e.g., public content feeds or game leaderboards).
Community Tables: Only the table owner (or a whitelisted set of public keys) can insert data. Useful for oracle publishers or protocol-owned datasets.
Comment on lines +28 to +29

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, bullets would be fine.


Ownership is defined at table creation via the wallet signature that initiates the DDL transaction.

## Paying for Tables and Inserts

Table creation is paid for using compute credits. Compute credits can be acquired through a few different means, mentioned in other parts of this documentation.

| Action | Cost |
|--------------------|-------------------|
| Table Creation | 20 SXT per Table |
| Namespace Creation | 20 SXT per Schema |
| Row Inserts | ~0.02 SXT per row |
Comment on lines +39 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to mention 20 SXT "+ gas"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just ~20 SXT.


## More Reading

* [PublicPermissionless Tables](./PUBLIC_TABLES.MD)
* [Community Tables](./COMMUNITY_TABLES.MD)

43 changes: 43 additions & 0 deletions tables/PUBLIC_TABLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Public/Permissionless Tables

PublicPermissionless tables allow anyone to insert data without requiring explicit permissions. The system automatically tracks who submitted each row using a `META_SUBMITTER` column, allowing for analytics.

## When to use PublicPermissionless Tables

- Open data collection (surveys, feedback, reports)
- Crowdsourced datasets
- Public registries and directories
- Community-driven data contributions
- Scenarios where you want open participation with accountability

# Example Use Case - Poll System

In this example we'll discuss a Poll System built on PublicPermissionless tables that allows users to vote on which movie will be the leader in box office earnings each week. To create the system, we will create a namespace and a table, then we'll show how users would 'vote' on the poll by inserting data into the table.

In this example we'll create the statements as if we are using the wallet address `0xABC8d709C80262965344f5240Ad123f5cBE51123`

So our namespace will be

`MOVIES_ABC8d709C80262965344f5240Ad123f5cBE51123`

And we'll use the following statements:

```sql
CREATE SCHEMA IF NOT EXISTS MOVIES_ABC8d709C80262965344f5240Ad123f5cBE51123;
CREATE TABLE IF NOT EXISTS MOVIES_ABC8d709C80262965344f5240Ad123f5cBE51123.VOTES (
MOVIE VARCHAR NOT NULL,
WEEK BIGINT NOT NULL,
PRIMARY_KEY(MOVIE, WEEK)
);
```
Which will, after being modified by the chain, result in a table like this;

| `MOVIE` (`VARCHAR`) | `WEEK` (`BIGINT`) | `META_SUBMITTER` (`BINARY`) |
|---------------------|-------------------| --------------------------- |
| Movie A | 2 | 0x000...user1address |
| Movie A | 2 | 0x000...user2address |
| Movie B | 2 | 0x000...user3address |

It's worth noting here that the table schema and the data submitted **should not include** the `META_SUBMITTER` column.

You can follow along in the [PublicPermission Tables Tutorial](../tutorials/public_tutorial/PUBLIC_PERMISSIONLESS_TUTORIAL.md)
Loading