Skip to main content
This guide walks you through the full integration from zero to your first private payment. By the end you will have an agent live on-chain, able to send and receive stealth payments with natural language.
Prerequisites:
  • Node.js 18 or later
  • A Wraith API key — sign up at wraith.dev
  • A wallet with signing capability (MetaMask, viem, ethers, or any EIP-191-compatible wallet)
1

Install the SDK

Install @wraith-protocol/sdk from npm:
npm install @wraith-protocol/sdk
2

Initialize the client

Import Wraith and construct a client with your API key:
import { Wraith, Chain } from "@wraith-protocol/sdk";

const wraith = new Wraith({
  apiKey: "wraith_live_abc123",
});
The Wraith client handles all communication with the managed TEE infrastructure. You never touch servers, keys, or chain-specific crypto directly.
3

Create an agent

An agent is your identity on the Wraith network. It gets a .wraith name, an on-chain address, and stealth keys — all derived inside TEE hardware.Sign a message with your owner wallet to prove ownership, then create the agent:
// 1. Sign a message with the owner wallet to prove ownership
const message = "Sign to create Wraith agent";
const signature = await wallet.signMessage(message);

// 2. Create the agent
const agent = await wraith.createAgent({
  name: "alice",
  chain: Chain.Horizen,
  wallet: "0xYourWalletAddress",
  signature: signature,
  message: message,
});

console.log(agent.info.id);                          // UUID
console.log(agent.info.addresses[Chain.Horizen]);     // "0x..."
console.log(agent.info.metaAddresses[Chain.Horizen]); // "st:eth:0x..."
Once created, the agent has:
  • A .wraith name (alice.wraith) registered on-chain
  • A stealth meta-address for receiving private payments
  • An AI agent inside the TEE ready to process commands
4

Fund the agent

On testnet, request funds via the faucet:
const response = await agent.chat("fund my wallet");
// Agent requests testnet tokens from the faucet
On mainnet, transfer funds directly to the address at agent.info.addresses[Chain.Horizen].
5

Send a stealth payment

Use natural language to send a private payment:
const response = await agent.chat("send 0.1 ETH to bob.wraith");

console.log(response.response);
// "Payment sent — 0.1 ETH to bob.wraith via stealth address 0x7a3f..."

console.log(response.toolCalls);
// [{ name: "send_payment", status: "success", detail: "..." }]
Behind the scenes the agent:
  1. Resolves bob.wraith to a stealth meta-address
  2. Generates a one-time stealth address from the meta-address
  3. Sends ETH to that stealth address
  4. Publishes an announcement so bob.wraith can detect the payment
6

Scan for incoming payments

Ask the agent to scan for payments sent to your stealth addresses:
const response = await agent.chat("scan for incoming payments");
// Agent scans the chain for announcements matching your stealth keys
The agent checks every on-chain announcement against your viewing key and returns only the payments that belong to you.

Other common operations

Check your balance

const response = await agent.chat("what's my balance?");
// Agent reports native + token balances
Or programmatically:
const balance = await agent.getBalance();
console.log(balance.native);  // "1.5"
console.log(balance.tokens);  // { ZEN: "100.0", USDC: "50.0" }

Withdraw funds

const response = await agent.chat("withdraw all to 0xMyWallet");
// Agent warns about privacy risks before executing
Withdrawing all stealth addresses to a single known wallet links every payment to your identity. The agent will flag this — read the privacy warning before confirming.

Reconnect to an existing agent

If you have already created an agent, reconnect without creating a new one:
// By agent ID
const agent = wraith.agent("agent-uuid-here");

// By owner wallet
const agent = await wraith.getAgentByWallet("0xYourWallet");

// By .wraith name
const agent = await wraith.getAgentByName("alice");

Error handling

All methods throw on failure. The error message comes from the server:
try {
  await agent.chat("send 100 ETH to bob.wraith");
} catch (err) {
  console.error(err.message); // "Insufficient balance"
}

Next steps

Stealth addresses

Understand the cryptography behind every private payment.

Agents

Learn about multichain agents, reconnection, and the full agent API.

TEE security

Understand the hardware guarantees protecting your keys.

Multichain agent guide

Deploy one agent across Horizen, Stellar, and Ethereum simultaneously.