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
  • Create a Mercury Account and get your Token
  • Installing the Mercury CLI
  • Setting up the project
  • Zephyr.toml
  • Cargo.toml
  1. Zephyr: Full Customization
  2. Learn
  3. Get Started: Set Up and Manage the Project

Create the Project

PreviousGet Started: Set Up and Manage the ProjectNextWriting the Program

Last updated 10 hours ago

Create a Mercury Account and get your Token

To do anything with Mercury you first need to create an account. This can be done from . Once you're done, make sure to save somewhere your API token, unique to your account and needed to access your Zephir program.

The token can always be found on the under the Active Subscriptions section and is renewed every 7 days.

For simplicity, you can load your mercury API token as a variable in your current shell. For example:

export MERCURY_JWT="your_api_token_here"

Installing the Mercury CLI

The Mercury CLI, which currently supports only Zephyr functionalities, is an essential tool for interacting with Mercury's cloud execution environment. While it's technically possible to use the API, we recommend using the CLI for easier development.

To install the CLI simply run:

cargo install mercury-cli

This should install the CLI, you can verify with

mercury-cli --version

Setting up the project

The mercury-cli takes care of setting up the project for us:

mercury-cli new-project --jwt value --name zephyr-hello-world

This will create the starting point for our Zephyr program: set up the Cargo.toml, add some compiler flags, a starting point in the lib.rs and create the zephyr.toml.

Set the --jwt value to whatever (soon to be fixed). As of now we noted that the command will return an error on the terminal: it should be fine, just check if the crate was crated in your directory.

Zephyr.toml

Every time you deploy your zephyr program, the zephyr toml gives the instructions to the backend of creating the tables it defines. In case these tables exist already they will be dropped. As a result, make sure that if you have already deployed and have ingested data and need to make only an update to the code logic, remove the tables from your zephyr.toml and place them in a copy of it.

As the last step for setting up our Zephyr program, we need to create and define a zephyr.toml configuration file. That is needed if your program will read from or write to some tables that you define.

name = "zephyr-hello-world"

[[tables]]
name = "test"

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

The above file means that we are creating a table "test" with "hello" as the only column and declaring that we may write to/read from it during the execution of our Zephyr program.

Note that col_type = "BYTEA" means that we can only store bytes in the database. Currently, this is the only supported data type (even though it will support built-in types in the future). That said, we recommend writing XDR structures to the database to ease decoding the client side with the existing Stellar tooling.

Cargo.toml

It's temporatily needed to manually git-source the zephyr-sdk dependency:

[dependencies]
zephyr-sdk = { git="https://github.com/xycloo/rs-zephyr-toolkit" }

This configuration mainly defines the tables your program will read from/write to and their structure. A more detailed explanation about zephyr.toml files can be found at , but here's an example configuration taken from the quickstart.

Mercury's app
dashboard's homepage
Understanding Zephyr.toml And Database Interactions