Open the app

API: transactions

Build routes for every action, submission, status, admission requests and the faucet.

Every action on the ledger is one transaction the API builds and the wallet signs:

  1. POST /v1/build/{action} checks the action against the register and returns an unsigned v0 transaction with a summary of what it will move. A refused action returns an error before anything is signed: NOT_FOUND for an offer or repo that doesn't exist, otherwise the program error or API refusal that stops it, as listed in Errors.
  2. The wallet signs transactionBase64.
  3. POST /v1/transactions/submit sends it, or records the signature of one the wallet sent itself.
  4. GET /v1/transactions/{id} reports its status until it settles.

A first settlement has a helper that does steps 2 to 4.

The build

Every build route returns the same shape.

FieldTypeDescription
idTransactionIdThe build's id. Submit and follow the transaction by it.
transactionBase64Base64The unsigned v0 transaction for the wallet to sign.
blockhashAddressThe blockhash the transaction was built on.
lastValidBlockHeightintegerThe block height after which the transaction can't land. Build again after it.
cosignedbooleantrue when the server adds a signature at submit (admission, which the operator co-signs). Submit it in relay mode.
summaryActionSummaryWhat the transaction will move, for the confirmation screen.

ActionSummary

FieldTypeDescription
actionstringThe build action.
descriptionstringOne sentence saying what moves.
legsSettlementLeg[]The legs the transaction will settle.
feeU64The settlement fee in cash atoms (take-offer).
repurchaseAmountU64Cash atoms to repay (take-repo, repay).
maturityTimestampWhen the repo matures (take-repo, repay). For take-repo it is the build time plus the term; the program fixes it when the transaction lands.
perUnitScaledBaseUnitsCash atoms per unit, scaled by 10^12 (pay-income).

The summary's legs use the same shape as a settlement's: SettlementLeg. Show them before the wallet signs: they are what the settlement will record.

Build routes

Every request names the signing wallet. Units, amounts and prices are strings; rates and terms are integers.

POST /v1/build/admit

Admits the wallet once its request is approved (Admission requests). The build is cosigned: submit it in relay mode, and the API adds the operator's signature.

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.

POST /v1/build/deposit

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
amountPositiveU64yesUSDC atoms to move from the wallet's cash ATA into free ledger cash.

POST /v1/build/withdraw

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
amountPositiveU64yesFree cash atoms to send to the wallet's cash ATA.

POST /v1/build/list-instrument

For an equity:

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe new instrument's code.
namestringyesIts name: text, at most 80 UTF-8 bytes.
kind"equity"yesequity or bond.

For a bond:

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe new instrument's code.
namestringyesIts name: text, at most 80 UTF-8 bytes.
kind"bond"yesequity or bond.
couponBpsintegeryesYearly coupon in basis points.
maturityTimestampyesMaturity, later than now.

POST /v1/build/issue

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe instrument code.
recipientAddressyesThe admitted wallet to credit.
unitsPositiveU64yesWhole units to credit to the recipient's free lane.

POST /v1/build/post-offer

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe instrument code.
side"buy" | "sell"yesbuy (a bid) or sell (an ask).
unitsPositiveU64yesWhole units offered.
pricePositiveU64yesCash atoms per unit.

POST /v1/build/cancel-offer

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
offerIdAddressyesThe Offer account's address.

POST /v1/build/take-offer

The summary includes the fee.

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
offerIdAddressyesThe Offer account's address.
unitsPositiveU64yesWhole units to fill, at most the offer's open size.

POST /v1/build/post-repo-offer

The cash locked is units × advancePerUnit.

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe instrument code.
unitsPositiveU64yesUnits the offer lends against. The cash locked is units times advancePerUnit.
advancePerUnitPositiveU64yesCash atoms advanced per pledged unit.
rateBpsintegeryesYearly rate in basis points.
termSecondsintegeryesRepo term in seconds.

POST /v1/build/cancel-repo-offer

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
repoOfferIdAddressyesThe RepoOffer account's address.

POST /v1/build/take-repo

The summary includes the repurchaseAmount and maturity, both fixed when the repo opens.

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
repoOfferIdAddressyesThe RepoOffer account's address.
unitsPositiveU64yesWhole units to pledge. Their advance must fit in the offer's available cash.

POST /v1/build/repay

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
repoIdAddressyesThe Repo account's address.

POST /v1/build/settle-default

Any wallet may build it; the wallet needn't be a member.

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
repoIdAddressyesThe Repo account's address.

POST /v1/build/pay-income

The summary includes perUnitScaled.

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe instrument code.
amountPositiveU64yesCash atoms to pay into the instrument from the issuer's free cash.

POST /v1/build/claim-income

FieldTypeRequiredDescription
walletAddressyesThe wallet's address.
codeCodeyesThe instrument code.

Submit

POST /v1/transactions/submit takes one of two bodies, by mode.

relay: the API sends the signed transaction.

FieldTypeRequiredDescription
buildIdTransactionIdyesThe id the build route returned.
idempotencyKeystringyesA key you choose, 1 to 128 characters. Resending the same submission with it returns the first result.
mode"relay"yesrelay: the API sends the signed transaction. wallet-sent: the wallet already sent it.
signedTransactionBase64stringyesThe transaction as the wallet signed it.

wallet-sent: the wallet signed and sent it itself, and the API follows its signature. Not for co-signed builds.

FieldTypeRequiredDescription
buildIdTransactionIdyesThe id the build route returned.
idempotencyKeystringyesA key you choose, 1 to 128 characters. Resending the same submission with it returns the first result.
mode"wallet-sent"yesrelay: the API sends the signed transaction. wallet-sent: the wallet already sent it.
signatureSignatureyesThe signature the wallet's send returned.

Submitting again with the same idempotencyKey and body sends nothing twice: it returns that transaction's status. The same key with a different build or body is an IDEMPOTENCY_CONFLICT. The response is a TxStatus.

Status

GET /v1/transactions/{id}, with the build's id, returns:

FieldTypeDescription
idTransactionIdThe build's id.
status"submitted" | "unconfirmed" | "confirmed" | "finalized" | "failed" | "expired"submitted, unconfirmed, confirmed, finalized, failed or expired.
signatureSignatureThe transaction signature, once known.
errorTxFailureWhy it failed, when status is failed.

Read it until the status is confirmed, finalized, failed or expired; the client's settled(status) says when. expired means the blockhash passed lastValidBlockHeight before the transaction landed: build again. A failure says where and why:

FieldTypeDescription
stage"build" | "wallet-rejected" | "wallet-changed" | "simulation" | "send" | "confirm"Where it failed: build, wallet-rejected, wallet-changed, simulation, send or confirm.
messagestringA sentence the app can show.
nextStepstringWhat to do next.
retryablebooleantrue when trying again can succeed.
programobjectThe program that refused it, for program errors.
program.addressAddressThe refusing program's address.
program.codeinteger | nullIts custom error code.
program.namestring | nullIts error name.

Admission requests

POST /v1/admissions asks the operator to admit a wallet and returns its admission state. The wallet signs the request itself (Wallet Standard signMessage, UTF-8) over this text, which admissionMessage({ wallet, entity, role, signedAt }) in the TypeScript client builds:

text
Agora admission request
Wallet: <wallet>
Entity: <entity>
Role: <role>
Signed at: <signedAt>

The entity is trimmed. The API accepts the signature for ten minutes after signedAt; an older one is a VALIDATION_ERROR on signedAt, and one made by another key is UNAUTHORIZED.

Sending the same entity and role again returns the request as it stands. A different entity or role replaces it, clears any rejection and sends it back for approval, approved at once where admissionMode is instant. An admitted wallet gets admitted.

FieldTypeRequiredDescription
walletAddressyesThe wallet to admit.
entitystringyesThe entity's name: text, at most 80 UTF-8 bytes.
role"holder" | "issuer"yesholder or issuer.
signedAtTimestampyesWhen the wallet signed the request. The API accepts it for ten minutes.
signatureSignatureyesThe wallet's Ed25519 signature over admissionMessage of this request, base58.

Faucet

POST /v1/faucet sends test USD and SOL to a wallet, where GET /v1/config reports faucetAvailable: true.

FieldTypeRequiredDescription
walletAddressyesThe wallet to fund.
FieldTypeDescription
walletAddressThe wallet's address.
cashAmountU64Test USD sent, in cash atoms.
lamportsU64SOL sent for fees and rent, in lamports.
signatureSignatureThe faucet transaction's signature.