Mercury Documentation
  • Get Started with Mercury
    • Pricing
    • Endpoints
    • Authentication
  • The Definitive Guide to Understanding The Mercury's Stack Vision
  • Retroshades
    • Introduction to Retroshades
    • Get Started
      • Importing the Retroshades SDK
      • Writing and Emitting Retroshades
      • Deploying to Mercury Retroshades
      • Querying Retroshades
  • Zephyr: Full Customization
    • Introduction
    • General concepts
      • Zephyr Programs
      • Accessing the Ledger: Contract Entries
      • Accessing the Ledger Meta: Contract Events
      • Database Interactions
      • Create Custom Callable APIs: Serverless Functions
      • Catchups
      • Using Soroban inside Zephyr
    • Quickstart
    • Learn
      • Introduction to Mercury's Cloud and the Zephyr Stack
      • Get Started: Set Up and Manage the Project
        • Create the Project
        • Writing the Program
        • Local Testing
        • Deploy
        • Data catchups/backfill
        • Monitor Execution
        • Querying
      • Database Interactions
        • Zephyr.toml: Define the Tables Structure
        • Understanding Database Interactions
        • Database Operations
      • Accessing the Ledger
      • Accessing Ledger Transition: Soroban Events
      • Working with Contract Custom Types
      • Working with Soroban SDK Types
      • Web Requests, Automation and Alerts.
      • Zephyr.toml Extensions: Indexes And Dashboard
      • Reading From Indexes/External Tables
      • Custom APIs - Serverless Functions
        • General Concepts
        • Custom RPC-alike Endpoints
        • Querying APIs for Composable Data
      • Data Catchups/Backfill
      • Custom Dashboards
        • Creating the Dashboard
        • Plotting: Simple
        • Complex Plotting
    • Support
  • Mercury "Classic"
    • Subscriptions
      • API Definition
    • Queries
      • Contract Events
      • Contract Data Entry Updates
      • Stellar Operations, Balances, and Account Objects
  • TUTORIALS
    • Zephyr
      • Self-hosting Zephyr
      • No-RPC Dapp
      • Indexing a DeFi liquidity pool (Blend)
      • Building a Secure DeFi Real-Time Bot Through Smart Accounts
      • Monitoring Large Deposits with Zephyr and Sending Web Alerts
    • Mercury Classic
      • Index and query contract events
Powered by GitBook
On this page
  • Choosing a Table's Structure
  • Table Naming
  1. Zephyr: Full Customization
  2. Learn
  3. Database Interactions

Zephyr.toml: Define the Tables Structure

The zephyr.toml is a crucial part of the newer versions of the Zephyr client-side tooling. The file is used to define the zephyr-related configurations of your rust crate. More specifically it defines the tables that your ingestion program will read from or write to during the execution. Besides the tables, you'll also have to define the columns for each of the tables you declare.

Choosing a Table's Structure

How can we define Zephyr tables then? Zephyr tables are effectively translated to PostgreSQL tables under the hood (that is, on the host server). In light of this, we recommend following a layout that is SQL-efficient.

Let's follow a simple example of how a zephyr.toml file with multiple tables would look:

zephyr.toml
name = "feedback-indexer"


// first table
[[tables]]
name = "feedback"

[[tables.columns]]
name = "source"
col_type = "BYTEA"

[[tables.columns]]
name = "hash"
col_type = "BYTEA"

[[tables.columns]]
name = "text"
col_type = "BYTEA"

[[tables.columns]]
name = "votes"
col_type = "BYTEA"


// second table
[[tables]]
name = "score"

[[tables.columns]]
name = "source"
col_type = "BYTEA"

[[tables.columns]]
name = "upvote"
col_type = "BYTEA"

Table Naming

For what concerns naming, we are currently leveraging the ease of packing string-alike objects into integers through Sorban symbols, i.e. we are using symbols for table and column names. This means that table/column names can only be up to 9 characters, and that supported characters are a-zA-Z0-9_.

This means that table names will likely have to be abbreviated: "current_sequence" won't work while "curr_seq" will.

PreviousDatabase InteractionsNextUnderstanding Database Interactions

Last updated 11 months ago

At the top of the file we always define the name of the program (this example is taken from the example). Next, we have two tables. First, we define for each table the table name, and then we specify the columns one by one.

onchain-stellar-complaints indexer