Skip to content

Commit c88ed99

Browse files
authored
Merge branch 'develop' into feat/issue-86-audit-summary-page
2 parents 6bbfc0b + 62d05de commit c88ed99

7 files changed

Lines changed: 1383 additions & 95 deletions

File tree

docs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,14 @@
145145
"guides/stellar-federation",
146146
"guides/stellar-custom-assets",
147147
"guides/stellar/stellar-liquidity-pool-swap",
148+
"guides/stellar/stellar-path-payment",
148149
"guides/wraith-names-stellar",
149150
"guides/ops/self-hosted-deployment"
150151
]
152+
},
153+
{
154+
"group": "Integrations",
155+
"pages": ["guides/integrations/nuxt"]
151156
}
152157
]
153158
},

getting-started.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ try {
149149
- [Single-Chain Agent Guide](guides/single-chain-agent) — deeper walkthrough
150150
- [Multichain Agent Guide](guides/multichain-agent) — deploy across multiple chains
151151
- [Bring Your Own Model](guides/bring-your-own-model) — use OpenAI or Claude instead of Gemini
152+
- [Stellar Networks Reference](reference/stellar-networks) — passphrases, RPC endpoints, contract IDs, and reset cadence for every Stellar network
152153
- [Stellar Fee Estimation & Budgeting](guides/stellar-fees) — learn about inclusion fees, Soroban resource fees, and fee bumps
153154
- [Stellar React Hooks](sdk/stellar-react-hooks) — React hooks for Stellar stealth address operations
154155
- [Stellar Troubleshooting](guides/stellar-troubleshooting) — fixes for common Stellar, Soroban, and Stealth errors

guides/integrations/nuxt.mdx

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
---
2+
title: "Nuxt integration"
3+
description: "Add Wraith to your Nuxt 3 app with auto-imported composables and SSR-safe patterns"
4+
---
5+
6+
Use the official Nuxt module to add Wraith to your Nuxt 3 application. The module auto-imports composables, handles SSR safety, and lets you use Wraith with native Nuxt patterns.
7+
8+
## Install the module
9+
10+
```bash
11+
npx nuxi module add @wraith-protocol/nuxt
12+
```
13+
14+
This registers the module in your `nuxt.config.ts`:
15+
16+
```ts
17+
export default defineNuxtConfig({
18+
modules: ["@wraith-protocol/nuxt"],
19+
wraith: {
20+
apiKey: process.env.NUXT_PUBLIC_WRAITH_API_KEY,
21+
},
22+
});
23+
```
24+
25+
Set your API key in `.env`:
26+
27+
```bash
28+
NUXT_PUBLIC_WRAITH_API_KEY=wraith_live_abc123
29+
```
30+
31+
## Auto-imported composables
32+
33+
The module auto-imports three composables. No manual imports needed.
34+
35+
### `useWraith()`
36+
37+
Returns a shared `Wraith` client configured with the API key from `nuxt.config.ts`.
38+
39+
```ts
40+
import { Chain } from "@wraith-protocol/sdk";
41+
42+
const wraith = useWraith();
43+
44+
const agent = await wraith.createAgent({
45+
name: "alice",
46+
chain: Chain.Horizen,
47+
wallet: walletAddress,
48+
signature: signature,
49+
});
50+
```
51+
52+
### `useWraithAgent()`
53+
54+
Returns the currently active agent, or `null` if no agent has been created yet.
55+
56+
```ts
57+
const agent = useWraithAgent();
58+
59+
if (agent) {
60+
const res = await agent.chat("send 0.1 ETH to bob.wraith");
61+
console.log(res.response);
62+
}
63+
```
64+
65+
### `useWraithBalance()`
66+
67+
Reactive balance state for the active agent. Refreshes on an interval.
68+
69+
```ts
70+
const { balance, refresh } = useWraithBalance();
71+
72+
// balance.value is a Ref<{ native: string; tokens: Record<string, string> }>
73+
console.log(balance.value.native); // "1.5"
74+
console.log(balance.value.tokens); // { ZEN: "100.0", USDC: "50.0" }
75+
```
76+
77+
## SSR gotchas
78+
79+
The Wraith SDK uses `fetch` and has no Node.js-specific dependencies. The managed agent client (`useWraith`, `useWraithAgent`) is safe to use during SSR. Crypto modules require client-side only.
80+
81+
### Crypto modules are client-only
82+
83+
If you import chain-specific crypto modules (`@wraith-protocol/sdk/chains/evm`, etc.), they must run client-side. These modules use `@noble/curves` which works in the browser but causes hydration mismatches during SSR.
84+
85+
Use dynamic imports guarded by `import.meta.client`:
86+
87+
```ts
88+
let generateStealthMetaAddress: typeof import("@wraith-protocol/sdk/chains/evm").generateStealthMetaAddress;
89+
90+
if (import.meta.client) {
91+
const evm = await import("@wraith-protocol/sdk/chains/evm");
92+
generateStealthMetaAddress = evm.generateStealthMetaAddress;
93+
}
94+
```
95+
96+
### Client-only components
97+
98+
For UI components that interact with Wraith, mark them with the `.client.vue` suffix or use `<ClientOnly>`:
99+
100+
```vue
101+
<template>
102+
<ClientOnly>
103+
<WraithDashboard />
104+
<template #fallback>
105+
<div class="skeleton">Loading Wraith dashboard...</div>
106+
</template>
107+
</ClientOnly>
108+
</template>
109+
```
110+
111+
### Module SSR configuration
112+
113+
The module registers a Nuxt plugin that initializes the `Wraith` client. It defaults to `ssr: false` (client-only). Toggle this in `nuxt.config.ts`:
114+
115+
```ts
116+
export default defineNuxtConfig({
117+
wraith: {
118+
apiKey: process.env.NUXT_PUBLIC_WRAITH_API_KEY,
119+
ssr: false, // default — runs Wraith client in browser only
120+
},
121+
});
122+
```
123+
124+
Set `ssr: true` to initialize the Wraith client on the server too. The composables will work during SSR, but crypto modules remain client-only regardless.
125+
126+
## Full send and receive example
127+
128+
This composable handles agent creation, sending stealth payments, and scanning for incoming payments:
129+
130+
```ts no-check
131+
import { Chain } from "@wraith-protocol/sdk";
132+
133+
export function useWraithPayment() {
134+
const wraith = useWraith();
135+
const agentState = useWraithAgent();
136+
const { balance, refresh: refreshBalance } = useWraithBalance();
137+
138+
const sending = ref(false);
139+
const error = ref("");
140+
const lastResponse = ref("");
141+
142+
const ensureAgent = async () => {
143+
if (agentState.value) return;
144+
145+
const newAgent = await wraith.createAgent({
146+
name: "alice",
147+
chain: Chain.Horizen,
148+
wallet: walletAddress,
149+
signature: signature,
150+
});
151+
agentState.value = newAgent;
152+
};
153+
154+
const send = async (to: string, amount: string, asset: string) => {
155+
sending.value = true;
156+
error.value = "";
157+
try {
158+
const res = await agentState.value!.chat(
159+
`send ${amount} ${asset} to ${to}`
160+
);
161+
lastResponse.value = res.response;
162+
await refreshBalance();
163+
return res;
164+
} catch (err) {
165+
error.value = (err as Error).message;
166+
throw err;
167+
} finally {
168+
sending.value = false;
169+
}
170+
};
171+
172+
const scan = async () => {
173+
const res = await agentState.value!.chat("scan for incoming payments");
174+
lastResponse.value = res.response;
175+
return res;
176+
};
177+
178+
return {
179+
agent: agentState,
180+
balance,
181+
sending,
182+
error,
183+
lastResponse,
184+
ensureAgent,
185+
send,
186+
scan,
187+
};
188+
}
189+
```
190+
191+
Use it in a component:
192+
193+
```vue
194+
<script setup lang="ts">
195+
const {
196+
balance,
197+
lastResponse,
198+
error,
199+
sending,
200+
ensureAgent,
201+
send,
202+
scan,
203+
} = useWraithPayment();
204+
205+
const recipient = ref("bob.wraith");
206+
const amount = ref("0.1");
207+
const asset = ref("ETH");
208+
209+
onMounted(() => ensureAgent());
210+
</script>
211+
212+
<template>
213+
<ClientOnly>
214+
<div>
215+
<div v-if="error" class="error">{{ error }}</div>
216+
217+
<section>
218+
<h2>Balance</h2>
219+
<p>{{ balance?.native ?? "—" }} {{ asset }}</p>
220+
</section>
221+
222+
<section>
223+
<h2>Send payment</h2>
224+
<input v-model="recipient" placeholder="bob.wraith" />
225+
<input v-model="amount" type="number" placeholder="0.1" />
226+
<select v-model="asset">
227+
<option>ETH</option>
228+
<option>USDC</option>
229+
<option>ZEN</option>
230+
</select>
231+
<button :disabled="sending" @click="send(recipient, amount, asset)">
232+
{{ sending ? "Sending..." : "Send" }}
233+
</button>
234+
<p v-if="lastResponse">{{ lastResponse }}</p>
235+
</section>
236+
237+
<section>
238+
<h2>Incoming payments</h2>
239+
<button @click="scan">Scan</button>
240+
</section>
241+
</div>
242+
<template #fallback>
243+
<p>Loading Wraith...</p>
244+
</template>
245+
</ClientOnly>
246+
</template>
247+
```
248+
249+
Payments sent via `send` go to a fresh stealth address. The recipient can detect them by calling `scan`. Both operations happen through the AI agent running in the TEE — you never touch chain-specific crypto directly.
250+
251+
## Configuration reference
252+
253+
Full `wraith` options in `nuxt.config.ts`:
254+
255+
| Option | Type | Default | Description |
256+
|---|---|---|---|
257+
| `apiKey` | `string` | Required | Your Wraith API key |
258+
| `ssr` | `boolean` | `false` | Enable server-side initialization of the Wraith client |
259+
| `baseUrl` | `string` | `"https://api.wraith.dev"` | API base URL override |
260+
| `ai.provider` | `"gemini"` \| `"openai"` \| `"claude"` | `"gemini"` | AI provider for agent chat |
261+
| `ai.apiKey` | `string` | `undefined` | Your AI provider API key |
262+
263+
## Type safety
264+
265+
Types ship with the module. Add them to your `tsconfig.json`:
266+
267+
```json
268+
{
269+
"compilerOptions": {
270+
"types": ["@wraith-protocol/nuxt"]
271+
}
272+
}
273+
```
274+
275+
All composable return types are inferred from `@wraith-protocol/sdk`. `useWraith()` returns `Wraith`, `useWraithAgent()` returns `WraithAgent | null`, and `useWraithBalance()` returns a typed reactive balance object.
276+
277+
## Next steps
278+
279+
- [Single-chain agent guide](/guides/single-chain-agent) — full agent lifecycle
280+
- [Multichain agent](/guides/multichain-agent) — deploy across multiple chains
281+
- [SDK overview](/sdk/overview) — all SDK entry points
282+
- [Bring your own model](/guides/bring-your-own-model) — use OpenAI or Claude

guides/stellar-quickstart.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ For the full error catalog see [Stellar Troubleshooting](/guides/stellar-trouble
248248
## Next steps
249249

250250
<CardGroup cols={2}>
251+
<Card title="Stellar Networks Reference" href="/reference/stellar-networks" icon="network-wired">
252+
Passphrases, RPC endpoints, Friendbot URLs, reset cadence, and contract IDs for testnet, Futurenet, and mainnet
253+
</Card>
251254
<Card title="Privacy Best Practices" href="/guides/privacy-best-practices" icon="shield">
252255
Scoring algorithm, withdrawal spacing, and what to avoid
253256
</Card>

0 commit comments

Comments
 (0)