Stellar Wallet logo — Documentation

This SDK helps you embed wallet features with a production-grade feel: address management, signing, balances, and webhook callbacks. No external links here — just clean, self-contained docs.

Getting started

  1. Create a project in your console (mock).
  2. Generate an API_KEY (mock).
  3. Install the SDK and initialize.

Install

npm install stellar-wallet-sdk
yarn add stellar-wallet-sdk

Configuration

Initialize the SDK in your app bootstrap. Keep credentials in env (mock keys shown).

import { Wallet } from 'stellar-wallet-sdk';

const wallet = new Wallet({
  apiKey: 'sw_test_123456',
  network: 'mainnet', // 'testnet' also available
  appName: 'stellar wallet'
});

API Reference

createAddress(asset: string)

Creates a new address for the asset. Assets: btc, eth, usdt, and more.

const addr = await wallet.createAddress('eth');
console.log(addr.public); // 0xabc... (mock)

getBalance(address: string)

Returns balance snapshot for a given address.

const bal = await wallet.getBalance('0xabc...');
console.log(bal); // { asset: 'ETH', amount: '0.53' } (mock)

sendTransaction(input: Tx)

Signs and broadcasts a transaction; resolves with hash (mock).

const tx = await wallet.sendTransaction({
  asset: 'ETH',
  to: '0x1234abcd...',
  amount: '0.25'
});
console.log(tx.hash); // 0xdeadbeef...

Webhooks

Use server endpoints to receive notifications (sample payloads below).

POST /webhook/payment
{
  "event": "payment_received",
  "asset": "USDT",
  "amount": "25.00",
  "address": "0xabc...",
  "txid": "0xdead..."
}

Examples

async function run() {
  const addr = await wallet.createAddress('btc');
  const bal  = await wallet.getBalance(addr.public);
  if (Number(bal.amount) > 0.001) {
    const tx = await wallet.sendTransaction({
      asset: 'BTC',
      to: 'bc1q....',
      amount: '0.001'
    });
    console.log('hash', tx.hash);
  }
}

Security

  • Keys never leave the device. Client-side encryption (mock).
  • Built-in rate limits and replay protection (mock).
  • Deterministic signing with device attestation (mock).

Authentication

Requests are authenticated via header. Use mock key sw_test_* в тестовых примерах.

HTTP headers

GET /v1/balance
      Authorization: Bearer sw_test_123456
      X-Client: stellar wallet
      

Environments

Testnet

For development: predictable responses, safe limits.

Mainnet

For production: increased limits, strict validation.

const wallet = new Wallet({
        apiKey: 'sw_test_123',
        network: 'testnet' // 'mainnet'
      });

Pagination & Filtering

Use the cursor to scroll through collections and filter by fields.

GET /v1/transactions?limit=25&cursor=tx_abc&asset=ETH&direction=out
{
        "data": [{ "hash": "0x...", "amount": "0.25", "asset": "ETH" }],
        "page": { "next_cursor": "tx_def" }
      }

Error Handling

Errors are normalized. Use the code and type for routing.

HTTP/1.1 400 Bad Request
      {
        "error": {
          "type": "validation_error",
          "code": "invalid_address",
          "message": "Address format is invalid"
        }
      }
switch (err.code) {
        case 'invalid_address':break;
        case 'insufficient_funds': break;
      }

FAQ

Is this a real SDK?

These docs are a realistic mock for demo purposes. Flows, naming and outputs mimic a production SDK.

Does it expose private keys?

No. Keys are simulated as local-only. Use your own KMS in a real app.

Can I use testnet?

Yes. Set network: 'testnet' in configuration (mock).