A first settlement
Get admitted, fund the account and take an offer, in the app or through the API.
A first settlement is three signed transactions: the admission, a deposit and a take. On Mainnet the faucet supplies the SOL and the test cash. Each one lands on the ledger as a settlement with its signature.
In the app
Connect a wallet
Open /app and choose your wallet under Connect a wallet. On Mainnet the list includes the Localnet wallet, which signs with a test key kept in the browser.
Fund the wallet
The Get test USD button at the top of the Admission page sends test USD and SOL to your wallet; the SOL pays the admission's rent and network fees.
Request admission
Enter the entity name, choose Holder and press Sign and request admission; your wallet signs the request as a message. On Mainnet the request is approved at once, and the page moves on to Sign your admission.
Sign your admission
Press Review admission, then Sign admission. The operator's key co-signs it, and your wallet pays the member account's rent.
Deposit
On your account page, in Ledger cash, choose Deposit, enter an amount, press Review deposit, then Sign and send. The cash arrives free.
Take an offer
Open Markets and an instrument, then choose an ask on its Offer board. Enter the units and press Review trade: the panel shows both legs and the settlement fee. Sign and settle.
Read it on the ledger
The take shows Settled with its signature. See it on the ledger opens it on the ledger as a trade, with each leg, its slot and its time in UTC.
Through the API
Every action goes the same way. A build route returns an unsigned transaction, the wallet signs it, POST /v1/transactions/submit sends it, and GET /v1/transactions/{id} reports its status until it settles.
The samples use AGORA_API for the API's address, which is https://api-production-98ed7929.up.railway.app on Mainnet.
Send a built transaction
This helper does the sign, submit and follow part for every action. sign is your wallet's transaction signer: it takes the built transaction as base64 and returns it signed, as base64. signMessage is its message signer (Wallet Standard signMessage), used once, for the admission request: it signs UTF-8 text and returns the signature as base58. The guides call send(build, sign).
import { createClient, settled, type ActionBuild } from '@agora/contract'
export const api = createClient(process.env.AGORA_API!)
export type Sign = (transactionBase64: string) => Promise<string>
export type SignMessage = (text: string) => Promise<string>
export async function send(build: ActionBuild, sign: Sign) {
const signedTransactionBase64 = await sign(build.transactionBase64)
let status = await api.submit({
mode: 'relay',
buildId: build.id,
signedTransactionBase64,
idempotencyKey: crypto.randomUUID(),
})
while (!settled(status.status)) {
await new Promise((resolve) => setTimeout(resolve, 1000))
status = await api.txStatus(build.id)
}
if (status.status === 'failed' || status.status === 'expired') {
throw new Error(status.error?.program?.name ?? status.error?.message ?? status.status)
}
return status.signature
}A refused build throws ApiClientError before anything is signed. Its body.error.programError.name names the program error that would have failed the transaction, or one of the few refusals only the API makes; Errors lists both.
Get admitted
import { admissionMessage } from '@agora/contract'
const body = { wallet, entity: 'Harbour Pension Trust', role: 'holder' as const, signedAt: new Date().toISOString() }
const request = await api.requestAdmission({ ...body, signature: await signMessage(admissionMessage(body)) })
if (request.approved) {
const build = await api.buildAdmit({ wallet })
await send(build, sign)
}curl -X POST "$AGORA_API/v1/admissions" -H 'content-type: application/json' \
-d '{"wallet":"<wallet>","entity":"Harbour Pension Trust","role":"holder","signedAt":"<ISO time>","signature":"<base58>"}'
curl -X POST "$AGORA_API/v1/build/admit" -H 'content-type: application/json' \
-d '{"wallet":"<wallet>"}'The request is signed by the wallet itself, so no one else can file or change it; Admission requests has the text it signs. The admission build comes back with cosigned: true: the API adds the operator's signature when you submit it, so submit it in relay mode.
Fund the account
await api.faucet({ wallet })
const deposit = await api.buildDeposit({ wallet, amount: '1000000000' })
await send(deposit, sign)curl -X POST "$AGORA_API/v1/faucet" -H 'content-type: application/json' \
-d '{"wallet":"<wallet>"}'
curl -X POST "$AGORA_API/v1/build/deposit" -H 'content-type: application/json' \
-d '{"wallet":"<wallet>","amount":"1000000000"}'Amounts are cash atoms as decimal strings: ledger cash has 6 decimals, so 1000000000 is 1,000.00 USD.
Take an ask
const { asks } = await api.book('CALDER')
const best = asks[0]
if (best) {
const build = await api.buildTakeOffer({ wallet, offerId: best.id, units: '10' })
console.log(build.summary.description, build.summary.fee)
const signature = await send(build, sign)
const { items } = await api.settlements({ account: wallet, limit: 1 })
console.log(signature, items[0]?.kind, items[0]?.legs)
}curl "$AGORA_API/v1/instruments/CALDER/book"
curl -X POST "$AGORA_API/v1/build/take-offer" -H 'content-type: application/json' \
-d '{"wallet":"<wallet>","offerId":"<ask id>","units":"10"}'
curl -X POST "$AGORA_API/v1/transactions/submit" -H 'content-type: application/json' \
-d '{"mode":"relay","buildId":"<build id>","signedTransactionBase64":"<signed>","idempotencyKey":"<any unique key>"}'
curl "$AGORA_API/v1/transactions/<build id>"
curl "$AGORA_API/v1/settlements?account=<wallet>&limit=1"The build's summary lists the legs the transaction will settle and the fee. The settlement that lands has kind trade and the same legs. What each field means is in API: transactions.