Counsel class exported from counsel.ts. Each method corresponds to a single endpoint on the counsel public API. All methods are async and throw on non-2xx responses. The placeBet method additionally throws if the XRP Ledger returns any result other than tesSUCCESS.
Interfaces
The following TypeScript interfaces are exported directly fromcounsel.ts. Import them alongside the class for typed access to return values.
CounselOptions
BetIntent
Payment is the xrpl package’s unsigned transaction type. tx is passed directly to client.autofill() and wallet.sign() inside placeBet.
constructor(opts: CounselOptions)
Instantiates the client. No network connection is made at construction time.
Base URL of the counsel deployment. Use
https://api.counsel.markets for the hosted instance.XRPL WebSocket node URL used by
placeBet when connecting to the ledger. Defaults to the XRPL testnet (wss://s.altnet.rippletest.net:51233).markets()
MarketV1 fields include: id, question, family, phase, status ("open" | "resolved" | "void"), pool_account, fee_rate, bet_cutoff, resolution_time, total_xrp, total_drops, and an outcomes array.
Each outcome in outcomes carries: index, label, destination_tag, pool_drops, pool_xrp, bets, implied_prob, and payout_per_unit.
Returns
Array of all markets currently tracked by the counsel indexer.
The SourceTag counsel expects on all Payment transactions. Automatically applied by
placeBet.market(id: string)
The market ID, a hex string such as
"9b6a290b0cc8c5be".The raw market object. Shape matches a single entry from the
markets() array.betIntent(id, account, outcome, amountXrp)
Market ID.
Your XRPL address (e.g.
"rYourAddress..."). Used as the Account field in the unsigned Payment.Zero-based index of the outcome you want to bet on. Corresponds to
OutcomeV1.index in the market’s outcomes array.Stake in XRP (not drops). For example,
5 means 5 XRP.Unsigned XRPL Payment transaction. Pass to
client.autofill() then wallet.sign().The XRPL address of the market’s pool account (the Payment destination).
The DestinationTag identifying the outcome on the pool account.
The SourceTag counsel requires for attribution. Already embedded in
tx.Confirmed stake in XRP as the server interpreted it.
positions(address: string)
The XRPL address to query. Must be a valid r-address.
The address that was queried.
Array of position objects, one per bet the address has placed. Each entry includes the market, outcome, stake, and settlement state.
leaderboard()
The leaderboard payload. Schema may evolve; treat as a raw object until a stable shape is published.
placeBet(seed, id, outcome, amountXrp)
Wallet.fromSeed(seed), autofills ledger sequence fields via client.autofill(), signs with wallet.sign(), submits with client.submitAndWait(), and verifies tesSUCCESS before returning. Opens an XRPL WebSocket connection for the duration of the call, then disconnects. The seed is never sent to the counsel server.
The bettor’s XRPL wallet seed. Passed to
Wallet.fromSeed() entirely client-side. Only the derived account address is sent to the counsel API.Market ID.
Zero-based outcome index.
Stake in XRP.
The validated transaction hash from the ledger (
res.result.hash), confirmed tesSUCCESS.