> ## Documentation Index
> Fetch the complete documentation index at: https://docs.counsel.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# counsel-js SDK Overview: Fetch, Sign, and Submit Bets

> counsel-js is a TypeScript client for counsel prediction markets. Bots fetch unsigned bet intents, sign with their own key, and submit directly to XRPL.

counsel-js is a thin TypeScript client for the counsel public API. Bots are first-class on counsel: your code fetches an unsigned bet intent, signs it with its own key, and submits the transaction directly to the XRP Ledger. counsel never holds a private key. Every bet carries counsel's `SourceTag`, so a bot's volume counts toward attribution, the same as any other participant.

## Installation

counsel-js is not yet published to npm. Copy `counsel.ts` directly into your project or reference it from the repository:

```bash theme={null}
# Copy sdk/counsel.ts directly into your project or install from source:
cp counsel.ts ./src/counsel.ts
```

The only runtime dependency is the official `xrpl` npm package:

```bash theme={null}
npm install xrpl
```

## Constructor

```typescript theme={null}
import { Counsel } from "./counsel";

const counsel = new Counsel({
  baseUrl: "https://api.counsel.markets",
  // wss: optional XRPL WebSocket node (defaults to testnet)
});
```

`baseUrl` is required. `wss` is optional, see [Network](#network) below.

## Quick Start

The following example covers the full place-a-bet flow: fetch open markets, preview the projected odds after your stake, then submit:

```typescript theme={null}
const { markets } = await counsel.markets();
const market = markets.find(m => m.status === "open");

const intent = await counsel.betIntent(market.id, walletAddress, 0, 5);
console.log("odds after bet:", intent.projected_implied_odds_after);

const hash = await counsel.placeBet(process.env.BOT_SEED!, market.id, 0, 5);
console.log("tx:", hash);
```

`betIntent` gives you a preview of how much your own stake moves the line before you commit, essential on a parimutuel market where every new stake shifts the implied probability. Only call `placeBet` once the projected odds still make sense for your model.

## Network

By default, `placeBet` connects to the XRPL testnet at `wss://s.altnet.rippletest.net:51233`. To target mainnet or a different node, pass `wss` in the constructor:

```typescript theme={null}
const counsel = new Counsel({
  baseUrl: "https://api.counsel.markets",
  wss: "wss://xrplcluster.com",
});
```

<Warning>
  Never commit your seed to source control. Load it from an environment variable (`process.env.BOT_SEED`) and keep it out of logs.
</Warning>

For the complete method signatures, parameter descriptions, and return type details, see the [SDK Reference](/sdk/reference).
