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:
CdwvX8HQX3r89DpjZEfZ2VmtsxCCVdejrpwd5qD25iHq| From | Read it as |
|---|---|
| TypeScript | PROGRAM_ID from @laplace/sdk, a web3.js PublicKey |
| Rust | laplace::ID |
| The IDL | its 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.
| Account | Seeds | SDK call |
|---|---|---|
Config | ["config"] | pda.config() |
| Bond vault | ["vault"] | pda.vault() |
| Fee escrow authority | ["escrow"] | pda.escrow() |
| Fee escrow token account, per mint | The associated token account of the escrow authority for the mint | pda.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.
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 accountEach 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:
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.
| Account | Seeds | SDK call |
|---|---|---|
Operator | ["operator", authority] | pda.operator(authority) |
Offer | ["offer", authority, model], with model the Model account's address | pda.offer(authority, model) |
Receipt | ["receipt", requester, nonce], with nonce as a u64 in 8 little-endian bytes | pda.receipt(requester, nonce) |
Dispute | ["dispute", receipt, index], with index as a u16 in 2 little-endian bytes | pda.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:
| Client | API address | RPC address |
|---|---|---|
createLaplace in @laplace/sdk | apiUrl | rpcUrl, 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:
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:
| From | Read it as |
|---|---|
| The chain | fee_recipient on the Config account |
| HTTP | protocol.feeRecipient in GET /v1/network |
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, base58Its 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.
| Value | On chain | Over HTTP |
|---|---|---|
| Protocol share of a finalized fee | Config.protocol_share_bps | protocol.shareBps in GET /v1/network |
| Winner's part of a lost bond | Config.slash_winner_bps | protocol.slashWinnerBps in GET /v1/network |
| Answer deadline, turn deadline, withdrawal cooldown | Config.answer_deadline_secs, turn_deadline_secs, withdraw_cooldown_secs | |
| A model's window and bond | window_secs and bond_lamports on its Model | windowSeconds and bondLamports in GET /v1/models/:slug |
| An offer's price and mint | price and mint on the Offer | GET /v1/offers?model= |
The app shows each model's values on its page under Models.