> For the complete documentation index, see [llms.txt](https://black-sheep-finance.gitbook.io/black-sheep-finance-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://black-sheep-finance.gitbook.io/black-sheep-finance-docs/getting-started/first-agent.md).

# Your first agent wallet

This walkthrough covers everything an agent wallet does, end-to-end.

## 1. Create the wallet

Via dashboard: **Dashboard → Agents → New agent**. Via SDK:

```ts
const agent = await bs.agents.create({ label: "research-bot" });
```

A fresh Solana keypair is generated server-side. The **public key** is returned to you; the **secret key** is encrypted at rest and never leaves the server.

## 2. Attach a policy

Without a policy, no spending is permitted. Set one:

```ts
await bs.agents.update(agent.id, {
  policy: {
    daily_limit_usdc: 200,
    max_tx_usdc: 25,
    approval_threshold_usdc: 50,
    allowlist: ["7xKX...vendor1", "9pQR...vendor2"], // optional
  },
});
```

Read the [policy reference](/black-sheep-finance-docs/core-concepts/policies.md) for the full evaluation order.

## 3. Fund it

Send USDC from any wallet, exchange, or your treasury to the agent's public key. On devnet, hit the **Airdrop SOL** button in the dashboard for gas, then mint test USDC from a faucet.

The agent needs:

* **SOL** for transaction fees (\~0.000005 SOL per tx).
* **USDC** for the actual payments.

## 4. Spend

```ts
const r = await bs.agents.send(agent.id, {
  to: "7xKX...",
  amount: 12.5,
  memo: "invoice #42",
});
```

Three possible outcomes:

| `r.status`         | What happened                                     |
| ------------------ | ------------------------------------------------- |
| `sent`             | Approved by policy, signed, and broadcast         |
| `pending_approval` | Amount ≥ approval threshold — waiting for a human |
| *(throws)*         | Blocked by policy (cap, allowlist, daily limit)   |

## 5. Observe

* **Transactions** — `bs.transactions.list()` or **Dashboard → Transactions**
* **Approvals** — **Dashboard → Approvals**
* **Audit log** — **Dashboard → Security**
* **Webhooks** — every state change can fire a signed POST to your endpoint


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://black-sheep-finance.gitbook.io/black-sheep-finance-docs/getting-started/first-agent.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
