— 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.
— DocumentationThis 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.
API_KEY (mock).npm install stellar-wallet-sdk
yarn add stellar-wallet-sdk
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'
});
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)
Returns balance snapshot for a given address.
const bal = await wallet.getBalance('0xabc...');
console.log(bal); // { asset: 'ETH', amount: '0.53' } (mock)
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...
Use server endpoints to receive notifications (sample payloads below).
POST /webhook/payment
{
"event": "payment_received",
"asset": "USDT",
"amount": "25.00",
"address": "0xabc...",
"txid": "0xdead..."
}
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);
}
}
Requests are authenticated via header. Use mock key sw_test_* в тестовых примерах.
GET /v1/balance
Authorization: Bearer sw_test_123456
X-Client: stellar wallet
For development: predictable responses, safe limits.
For production: increased limits, strict validation.
const wallet = new Wallet({
apiKey: 'sw_test_123',
network: 'testnet' // 'mainnet'
});
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" }
}
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;
}
These docs are a realistic mock for demo purposes. Flows, naming and outputs mimic a production SDK.
No. Keys are simulated as local-only. Use your own KMS in a real app.
Yes. Set network: 'testnet' in configuration (mock).