Sphere SDK
Identity, wallets, private communication, and peer-to-peer settlement for autonomous economic agents.
- Source repo
- unicity-sphere/sphere-sdk
- Stars
- ★ 5.4k
- Last updated
- 1d ago
- License
- MIT
- Primary language
- TypeScript
- FA score
- 53/100 · Major gaps
At a glance
- How it runs
- Works with
- Universal · cross-platform
- Cost
- Free, no paid service needed
- Setup effort
- Medium · a few setup steps
- You'll need
- Typical use
- A browser-wallet or dApp team can combine localStorage or IndexedDB with
ConnectClient/ConnectHostand the Sphere extension or popup flow. - Not a fit if
- Teams that need fully self-custodied token inventory — the wallet-api backend holds it
- Teams needing working mainnet or dev transfers now — v1 gateways fail with AGGREGATOR_ERROR
- Projects wanting zero-config setup — you must supply a gateway API key and wallet-api deployment
- Source review
- 53/100 · Major gaps 1 safety controls not found
What does this agent do, and when should you use it?
Sphere SDK is a modular TypeScript wallet SDK for the Unicity state transition network, with documented browser and Node.js implementations. Its Sphere entry point composes identity, payments, payment requests, market intents, Nostr direct messages, and NIP-29 group chat. Wallet keys remain on the client, while the wallet-api backend holds token inventory and receives engine-certified transfers through per-user mailboxes. Base providers supply storage, Nostr transport, and oracle configuration; payment functionality requires a second configuration layer added with createWalletApiProviders. The SDK supports HD addresses, replaceable payment transport ports, browser or file-backed persistence, and wallet-to-dApp communication, making it suitable for teams embedding economic identity and settlement in agents, services, dApps, or wallet interfaces.
An application starts with createBrowserProviders or createNodeProviders to construct storage, Nostr transport, and oracle configuration, then attaches the required wallet-api configuration with createWalletApiProviders before calling Sphere.init. The SDK derives identities and multiple addresses with BIP39/BIP32, registers or recovers nametags, and exposes a primary DIRECT:// address. sphere.payments lists assets and history, drains incoming mailbox transfers, self-mints testnet tokens, and executes send() through durable transfer intents; completed v2 CBOR token blobs are proof- and ownership-checked before entering the balance. sphere.payments.requests creates, pays, declines, and tracks requests with encrypted memos, while sphere.market exposes a signed intent bulletin board with semantic search and a live feed. sphere.communications sends and receives NIP-17 encrypted direct messages, and the optional sphere.groupChat module uses a separate NIP-29 relay for groups, invitations, messages, and moderation. Additional interfaces cover the Connect protocol, dynamic relay management, encrypted wallet export/import, optional CoinGecko prices, and crypto, currency, hashing, and Base58 utilities.
- A browser-wallet or dApp team can combine localStorage or IndexedDB with
ConnectClient/ConnectHostand the Sphere extension or popup flow. - A developer building autonomous trading agents can give each agent a locally held identity, resolve recipients through nametags or
DIRECT://addresses, and settle withsphere.payments.send(). - A Node.js service or batch application can use file-backed storage and a stable
deviceId, explicitly callreceive()to drain its mailbox, and resume unfinished transfers after restart. - An application collecting payments can create requests through
sphere.payments.requests, include encrypted memos, and react topending,settling,paid,rejected, andexpiredstates. - A product requiring agent-to-agent communication can use NIP-17 private messages or enable NIP-29 groups with private invitations, unread counts, and administrator or moderator controls.
- A team testing Unicity v2 asset flows can self-mint on testnet/testnet2 and exercise multi-address wallets, transfer recovery, and mailbox delivery.
How do you install or deploy this agent?
Install the SDK package:
npm install @unicitylabs/sphere-sdkThe documented Node.js setup also requires ws, although the source does not provide its exact installation command. The CLI is maintained as a separate package and can be installed when needed:
npm install -g @unicity-sphere/cli
sphere --helpOperational payments additionally require access to a v2 gateway, a wallet-api deployment, and the appropriate oracle API key. The published testnet2 key may be used in client-side test code; a mainnet key must remain secret in the deployment environment.
How do you use this agent?
Browser initialization has two required provider layers. This example creates the base providers, attaches wallet-api, initializes a wallet, and submits a transfer:
import { Sphere } from '@unicitylabs/sphere-sdk';
import { createBrowserProviders } from '@unicitylabs/sphere-sdk/impl/browser';
import { createWalletApiProviders } from '@unicitylabs/sphere-sdk/impl/shared/wallet-api';
const base = createBrowserProviders({
network: 'testnet',
oracle: { apiKey: 'sk_ddc3cfcc001e4a28ac3fad7407f99590' },
});
const providers = createWalletApiProviders(base, {
baseUrl: 'https://wallet-api.unicity.network',
network: 'testnet2',
deviceId: 'my-stable-device-id',
});
const { sphere, created, generatedMnemonic } = await Sphere.init({
...providers,
autoGenerate: true,
});
if (created && generatedMnemonic) {
console.log('SAVE THIS RECOVERY PHRASE:', generatedMnemonic);
}
const result = await sphere.payments.send({
recipient: '@alice',
amount: '1000000',
coinId: 'UCT',
memo: 'hello',
});
console.log(result.status);
const { transfers } = await sphere.payments.receive();
console.log(transfers);
console.log(await sphere.payments.assets());Amounts must be decimal strings rather than JavaScript numbers. The recipient must have a published identity containing a chain public key, or the call fails with INVALID_RECIPIENT. A result with status === 'completed' and deliveryPending === true is already certified on-chain; only mailbox delivery is deferred, so the UI must not report it as a payment failure. If send() throws CERTIFICATION_UNCONFIRMED, do not issue a fresh send() because the original intent may already be certified; the SDK resumes it automatically under the same transferId, while a new call could double-pay the recipient. For wallets holding real value, pass a user password to Sphere.init, Sphere.create, or Sphere.load instead of relying on the built-in default-key obfuscation.
What are this agent's strengths and limitations?
- Durable server-side transfer intents resume under the same
transferId, covering crashes and partially committed outcomes without intentionally creating a second spend. - Keys stay on the client while wallet-api handles inventory and mailbox delivery, and every incoming token is proof- and ownership-verified before it affects the balance.
- One SDK combines payments, requests, signed market intents, NIP-17 direct messages, NIP-29 groups, multi-address wallets, and the Connect protocol.
- Documented provider implementations cover browsers and Node.js, while the money-port contracts and
paymentsV2Transportseam support custom hosts and offline test replacements. - The package includes practical supporting features such as strict amount parsing, encrypted import/export, dynamic relay management, and optional CoinGecko price data.
- Payments are not a purely client-side or self-custodied inventory design: the wallet-api backend holds token inventory, sessions, and recipient mailboxes.
- Initialization requires both the base-provider layer and wallet-api layer, with network configuration in both places; omissions cause
INVALID_CONFIG. - Mainnet and dev still target v1-era aggregators, so
sendandmintfail withAGGREGATOR_ERRORuntil those gateways move to v2. CERTIFICATION_UNCONFIRMEDrequires specialized application handling and must never trigger a fresh send, or automatic recovery of the original intent may lead to a double payment.- There is no bundled default gateway API key; Node.js also requires
ws, and operation depends on gateway, wallet-api, and Nostr relay availability. - Without a user-supplied password, the seed receives only built-in-key obfuscation at rest, which is unsuitable for a wallet holding real value.
How does this agent compare with similar options?
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Sphere SDK This agent | 53 · Major gaps | Library / SDKFree | ★ 5.4k | 1d ago | TypeScript | — |
| TanStack AI | 76 · Some gaps | Library / SDKFree + model costs | ★ 3.2k | 4d ago | TypeScript | OpenAI API · Claude API |
| Deuz SDK | 69 · Some gaps | Library / SDKFree + model costs | ★ 563 | 2d ago | TypeScript | OpenAI API · Claude API |
| TrueForge | 67 · Some gaps | CLIFree + model costs | ★ 6.3k | today | TypeScript | OpenAI API · Claude API |
How does FollowAgents rate this agent?
Why each dimension lost points
Evidence shows: SDK uses modular port design, keys stay local, server holds tokens, but no user confirmation mechanism (e.g., before sending). Data flow transparency is good, docs clearly state payments go through wallet-api not Nostr, and public testnet API key is disclosed. Sensitive data handling: supports password encryption (PBKDF2), but key storage details not detailed. Dependency security: relies on noble crypto libraries, but no dependency audit or vulnerability scan evidence. External effects: payments and messaging have clear external effects, but no rollback or revert mechanism. Source attribution: publisher unverified, but repo has clear author and license. Deductions: missing user confirmation, rollback mechanism, and dependency security evidence.
Evidence shows: docs and code examples consistent, error handling clear (e.g., CERTIFICATION_UNCONFIRMED not re-sendable). Dependency availability: relies on multiple external services (gateway, relay), but no offline or degradation plan. Failure messages: detailed error codes and recovery guidance. Deductions: external service availability not fully addressed.
Evidence shows: targets browser, Node.js, CLI, and dApp integration, covering payments, messaging, group chat. Capability boundaries clear: distinguishes payment and messaging channels. Trigger precision: event-driven, e.g., transfer:incoming. Environment fit: supports browser and Node.js, but no mobile. Deductions: no mobile support.
Evidence shows: README well-structured, install notes detailed, naming stable (e.g., createBrowserProviders). Examples abundant, including quick start and E2E tests. Known limitations: docs mention mainnet/dev still v1 protocol, payments fail. License MIT. Versioning: version number present, but no CHANGELOG. Maintenance responsibility: publish workflow exists, but maintainers not explicit. Deductions: missing CHANGELOG and explicit maintainer info.
Evidence shows: output usability high, clear APIs and events. Marginal value: provides identity, wallet, and payment capabilities for autonomous economic agents, unique value. Cost-benefit: relies on multiple external services, may increase deployment cost. Deductions: cost-benefit evidence insufficient.
Evidence shows: README claims consistent with code examples, tests provide E2E verification. Cross-source: docs and tests corroborate, but no independent third-party verification. Fact-inference separation: docs clearly distinguish facts (e.g., network config) from inferences (e.g., security). Deductions: limited cross-source evidence.
- Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
- Publisher unverified; assess trust risk before use.
- Payment operations are irreversible, and CERTIFICATION_UNCONFIRMED errors must not be re-sent; handle with care.
- Relies on multiple external services (gateway, relay); ensure their availability and security.
- Testnet API key is public, but mainnet key must be kept secret.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
v0.8.0 v0.8.0 — UXF Inter-Wallet Transfer Protocol + Profile-layer hardening
Release notes excerpt
178 PRs promoted from integration/all-fixes to main. - Release PR: [#345](https://github.com/unicity-sphere/sphere-sdk/pull/345) - Tag points at: af41bea6fc36 - Period covered: ~4 months of accumulated profile-layer, UXF, recovery, and connectivity work since the previous release lineage (PRs #128–#130 → #303–#342). ⚠️ Breaking: UXF wire-shape default flip …View on GitHub ↗ -
Release notes excerpt
Bug Fixes - CLI process exit: Fix CLI commands hanging ~10s after completion due to lingering Nostr WebSocket handles - Instant split change token: Fix sender losing change token when process.exit() killed background proof collection before completion Changes - InstantSplitExecutor.submitBackgroundV5 now returns a trackable Promise<void> instead of fire-and-forget - PaymentsModule tracks background promises and exposes waitForPendingOperations() for callers to await completion - CLI send command awaits pending background operations before exiting …View on GitHub ↗
FAQ
Where are keys and tokens stored?
Does deliveryPending mean that payment failed?
status === 'completed', the spend succeeded. deliveryPending === true means certification is complete but delivery to the recipient's wallet-api mailbox was deferred and will be retried.Can an application retry after CERTIFICATION_UNCONFIRMED?
send(). The transfer may already be certified, and the SDK retains and resumes the original intent with the same transferId; sending again can pay the recipient twice.Which documented networks currently support sending and self-minting?
testnet aliases the testnet2 v2 gateway at networkId 4. The documentation states that mainnet and dev still use v1-era aggregators, so their send and mint operations currently fail.