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.
string
required
Base URL of the counsel deployment. Use
https://api.counsel.markets for the hosted instance.string
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
MarketV1[]
Array of all markets currently tracked by the counsel indexer.
number | null
The SourceTag counsel expects on all Payment transactions. Automatically applied by
placeBet.market(id: string)
string
required
The market ID, a hex string such as
"9b6a290b0cc8c5be".Record<string, unknown>
The raw market object. Shape matches a single entry from the
markets() array.betIntent(id, account, outcome, amountXrp)
string
required
Market ID.
string
required
Your XRPL address (e.g.
"rYourAddress..."). Used as the Account field in the unsigned Payment.number
required
Zero-based index of the outcome you want to bet on. Corresponds to
OutcomeV1.index in the market’s outcomes array.number
required
Stake in XRP (not drops). For example,
5 means 5 XRP.Payment
Unsigned XRPL Payment transaction. Pass to
client.autofill() then wallet.sign().string
The XRPL address of the market’s pool account (the Payment destination).
number
The DestinationTag identifying the outcome on the pool account.
number
The SourceTag counsel requires for attribution. Already embedded in
tx.number
Confirmed stake in XRP as the server interpreted it.
object
object
positions(address: string)
string
required
The XRPL address to query. Must be a valid r-address.
string
The address that was queried.
unknown[]
Array of position objects, one per bet the address has placed. Each entry includes the market, outcome, stake, and settlement state.
leaderboard()
Record<string, unknown>
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.
string
required
The bettor’s XRPL wallet seed. Passed to
Wallet.fromSeed() entirely client-side. Only the derived account address is sent to the counsel API.string
required
Market ID.
number
required
Zero-based outcome index.
number
required
Stake in XRP.
string
The validated transaction hash from the ledger (
res.result.hash), confirmed tesSUCCESS.