Reference

Addresses

The program id per cluster, the config and escrow accounts, and the model accounts.

Every address on Laplace is either the program id or derived from it. This page gives the program id, the derivation of each fixed account with the SDK call that returns it, and where a client reads the network's API address, RPC address and fee recipient.

The program id

The laplace program has one id, the same on every cluster:

Text
CdwvX8HQX3r89DpjZEfZ2VmtsxCCVdejrpwd5qD25iHq
FromRead it as
TypeScriptPROGRAM_ID from @laplace/sdk, a web3.js PublicKey
Rustlaplace::ID
The IDLits address field

Fixed accounts

These exist once per program. Each is a program-derived address under the program id, found with PublicKey.findProgramAddressSync(seeds, PROGRAM_ID). A seed written as a quoted word is its ASCII bytes.

AccountSeedsSDK call
Config["config"]pda.config()
Bond vault["vault"]pda.vault()
Fee escrow authority["escrow"]pda.escrow()
Fee escrow token account, per mintThe associated token account of the escrow authority for the mintpda.escrowToken(mint)
The judge's Model["model", "judge"]pda.model('judge')
The market model's Model["model", "market"]pda.model('market')

The escrow token account follows the Associated Token program's own derivation: seeds [escrow authority, token program id, mint] under ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL, with the SPL Token program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. There is one per mint that an offer has been taken in.

TypeScript
import { pda, PROGRAM_ID } from '@laplace/sdk'

PROGRAM_ID.toBase58()     // the program id
pda.config()              // Config
pda.vault()               // the bond vault
pda.escrow()              // the fee escrow authority
pda.escrowToken(mint)     // the fee escrow's token account for a mint
pda.model('judge')        // the judge's Model account
pda.model('market')       // the market model's Model account

Each call returns a PublicKey. The API returns the same model addresses as address in GET /v1/models and GET /v1/models/:slug.

In a Rust program the same addresses come from Pubkey::find_program_address:

Rust
let (config, _) = Pubkey::find_program_address(&[b"config"], &laplace::ID);
let (judge, _) = Pubkey::find_program_address(&[b"model", b"judge"], &laplace::ID);

Accounts per key

The other accounts are derived from the keys they belong to.

AccountSeedsSDK call
Operator["operator", authority]pda.operator(authority)
Offer["offer", authority, model], with model the Model account's addresspda.offer(authority, model)
Receipt["receipt", requester, nonce], with nonce as a u64 in 8 little-endian bytespda.receipt(requester, nonce)
Dispute["dispute", receipt, index], with index as a u16 in 2 little-endian bytespda.dispute(receipt, index)

nonce is a bigint and index a number in the SDK. A key is its 32 bytes. Program accounts gives the fields behind each address.

pdas(programId) returns the same nine derivations under another program id, for a deployment of the program at a different address.

The API and RPC addresses

The network's API address and RPC address are deployment values. A client is given them and passes them on:

ClientAPI addressRPC address
createLaplace in @laplace/sdkapiUrlrpcUrl, or connection with a web3.js Connection
The laplace CLI--api, or the LAPLACE_API variable--rpc, or the LAPLACE_RPC variable

The API also relays JSON-RPC to the cluster at POST /v1/rpc, so a browser that knows only the API address has an RPC address as well:

TypeScript
import { createLaplace } from '@laplace/sdk'

const laplace = createLaplace({ rpcUrl: `${apiUrl}/v1/rpc`, apiUrl })

GET /health on the API address answers { "status": "ready" } once the API is reading the program on its cluster.

The fee recipient

The fee recipient is the wallet that receives the protocol's share of each finalized fee and its part of each lost bond. It is a field of Config, set by the admin, and is read two ways:

FromRead it as
The chainfee_recipient on the Config account
HTTPprotocol.feeRecipient in GET /v1/network
TypeScript
import { createLaplace, decode, pda } from '@laplace/sdk'

const laplace = createLaplace({ rpcUrl, apiUrl })

const info = await laplace.connection.getAccountInfo(pda.config())
const { feeRecipient } = decode.config(info!.data)   // a PublicKey

const network = await laplace.api.network()
network.protocol.feeRecipient                         // the same key, base58

Its token account for a mint, which finalize pays the share into, is the associated token account of that wallet for the mint.

Other values of the network

The values the admin and the publishers set are read from the same places.

ValueOn chainOver HTTP
Protocol share of a finalized feeConfig.protocol_share_bpsprotocol.shareBps in GET /v1/network
Winner's part of a lost bondConfig.slash_winner_bpsprotocol.slashWinnerBps in GET /v1/network
Answer deadline, turn deadline, withdrawal cooldownConfig.answer_deadline_secs, turn_deadline_secs, withdraw_cooldown_secs
A model's window and bondwindow_secs and bond_lamports on its ModelwindowSeconds and bondLamports in GET /v1/models/:slug
An offer's price and mintprice and mint on the OfferGET /v1/offers?model=

The app shows each model's values on its page under Models.