🔢 Index Program
The Index Program can create virtual namespaces for indexing Solana accounts on-chain. It provides key-value stores (KVS) for mapping account addresses to more predictable names. It supports creating indicies with either serial namespaces (0, 1, 2, 3 ... like an array) or freeform namespaces ("foo", "bar", "baz" ... like a hashmap). It additionally supports constant-time "reverse-lookup" searches from an address to its name in an index.
👉 Getting Started
Integrate and build
To integrate with the Index program, add it to your dependencies (see CPI Examples for sample code snippets):
# Cargo.toml
index-program = { version = "0.1.0" }
Hack around
To download and play with the code, clone the repo:
# Terminal
Submit an improvement
If you spot a bug or want to submit a improvement, join the Faktor Discord and come say hello! We're a group of people building public key infrastructure (PKI) and payments systems on Solana.
⚙️ How It Works
🦀 CPI Examples
The code snippets in this section are for Solana programs that need to create and manage their own on-chain indices. These examples assume the program has a singleton "program authority account" for signing instructions on behalf of the program.
Creating an index
This example instruction create_my_index
displays a program creating a freeform index in a custom namespace. Since the program signs the create_index
instruction with its authority account (a PDA), the Index Program marks the authority as the index's owner – guaranteeing only the program authority may write to the index.
// create_my_index.rs
use ;