For developers

One call asks a model. One call waits for the answer to be final. A program reads it with one crate.

1

Ask in one call

ask tokenizes the input, takes the cheapest live offer and sends the request. It returns the receipt. final resolves once the window has closed with nothing standing against the answer.

ask.ts
import { createLaplace } from '@laplace/sdk'

const laplace = createLaplace({ rpcUrl, apiUrl, wallet })

const receipt = await laplace.ask('judge', {
  claim: 'The bridge opened in 1932.',
  evidence: 'The bridge opened to traffic in March 1932.',
})
const answer = await laplace.final(receipt) // { model, inputHash, output }
or from a shell
laplace ask market "Shipments rose 18% in the third quarter, above guidance."
2

Read a receipt from a program

Your program takes the receipt account and calls read. It returns the model, the input hash and the output, and only when the receipt is final.

your program
use laplace_receipt::{read, Final};

// inside your instruction, with the receipt account passed in:
let Final { model, input_hash, output } = laplace_receipt::read(&ctx.accounts.receipt)?;
// errors unless the account is owned by the laplace program and its state is final
3

Price an answer by its bond and its window

A wrong answer costs its operator the model’s bond, and anyone has the model’s window to prove it wrong. Use a model whose bond is worth more than a wrong answer could gain, and act once the receipt is final.

Bonds and windows

Reading the network

What it is used for

  • Resolve a market

    The market stores the judge’s model and the hash of its question. To resolve, anyone passes a final receipt; the program checks both and pays out on the label.

  • Gate a payment

    An escrow holds the payment with the model and input hash it was bought for. A final receipt for that pair releases it; nothing else does.

  • Audit an agent

    Every model call the agent makes goes through ask. Its decisions are receipts, so any of them can be run again and challenged while its window is open.