Getting Started
Requirements
| Tool | Version |
|---|---|
| Bun | 1.3.0 |
| Postgres | 15 or later |
| Anchor CLI | 1.1.2 |
| Solana CLI | 4.1.1 |
| Rust | 1.89.0 |
The devnet commitment program is deployed at 5SwaBH3pXzEKhmL6pbqZ1JgeDiGaf6i5oVj8951RX9sm.
Install
bun install
Database
createdb toda
cd packages/db
bun x drizzle-kit migrate
Default connection:
postgres://postgres:postgres@localhost:5432/toda
Set DATABASE_URL when the local user or database differs.
Environment
cp .env.example .env
Required values:
DATABASE_URL="postgres://.../toda"
JWT_SECRET="<at least 32 characters>"
MASTER_ENCRYPTION_KEY="<base64 32-byte key>"
TODA_PROGRAM_ID="5SwaBH3pXzEKhmL6pbqZ1JgeDiGaf6i5oVj8951RX9sm"
Generate an encryption key with openssl rand -base64 32.
MASTER_ENCRYPTION_KEY and JWT_SECRET can provide plaintext access. Store both in a secrets manager.
Anchor authority
bin/dev-keypair.sh
The script creates and funds a devnet authority at ./authority-keypair.json. The file is gitignored.
Run
bun run dev
| Service | URL |
|---|---|
| Dashboard | http://localhost:3000 |
| API | http://localhost:3001 |
| Extension API | http://localhost:3002 |
| Docs | http://localhost:3003 |
Run the anchor service separately:
bun run apps/api/src/worker/anchor.ts
Write a memory
Connect a wallet in the dashboard and create an API key.
import { Toda } from "@toda/sdk";
const toda = new Toda({
apiUrl: "http://localhost:3001",
apiKey: process.env.TODA_API_KEY!,
});
const receipt = await toda.remember(
"Deployments run on Fridays.",
{ kind: "preference" },
);
The receipt is returned before anchoring.
await toda.verify(receipt.id); // false until anchored
The default seal policy commits at 64 pending leaves or after five minutes.
Read the commitment
const tip = await readUserCommit(connection, new PublicKey(ownerPubkey));
console.log({
root: bytesToHex(tip.merkleRoot),
count: tip.memoryCount,
nonce: tip.nonce,
});
Build the programs
anchor build
bun test programs/toda-commit/tests/ programs/toda-staking/tests/
After an IDL change, update the committed copies under packages/solana/src/idl/.