Skip to content

[good-first-issue] [Docs] Create SDK Quickstart Guide (docs/SDK_GUIDE.md) #6

Description

@IyanuOluwaJesuloba

Summary
The file docs/SDK_GUIDE.md is referenced in the codebase but does not exist. Specifically, in sdk/src/registry.ts line 119:

ts
throw new StellarMindError(
  'find() requires an indexer integration — see docs/SDK_GUIDE.md for setup',
  'NOT_IMPLEMENTED'
);

New developers trying to use the SDK have no guide. This is a documentation issue and is a great first contribution — no Rust or Soroban knowledge required.

What Needs to Be Written
Create docs/SDK_GUIDE.md with the following sections:

Section 1 — Installation

bash
npm install @stellarmind/sdk
# or
yarn add @stellarmind/sdk

Section 2 — Quick Start (5 minutes)
Show the simplest possible working example from zero to first agent query:

ts
import { StellarMind } from '@stellarmind/sdk'

const mind = new StellarMind({ network: 'testnet' })

// Fetch a specific agent
const agent = await mind.registry.getAgent('flux-image-gen-v1')
console.log(`${agent.name} — ${agent.priceDisplay} — ${agent.reputationDisplay}`)

Section 3 — Registering an Agent
Complete working example with all required fields explained:

ts
import { StellarMind, USDC_ISSUER } from '@stellarmind/sdk'
import { Keypair } from '@stellar/stellar-sdk'

const mind = new StellarMind({ network: 'testnet' })
const keypair = Keypair.fromSecret('YOUR_SECRET_KEY') // never commit this

await mind.registry.register({
  id: 'my-agent-v1',
  name: 'My AI Agent',
  description: 'What my agent does',
  capabilities: ['text-generation', 'summarization'],
  pricePerCall: '0.01',          // 0.01 USDC per call
  paymentAsset: 'USDC',
  paymentIssuer: USDC_ISSUER.testnet,
  endpointUrl: 'https://my-api.com/v1',
}, keypair)

Section 4 — Creating a Spending Policy

ts
const policyId = await mind.policy.create({
  agent: 'GBKR...2XPL',          // agent's Stellar address
  maxPerTx: '0.50',               // max $0.50 per single payment
  dailyLimit: '10.00',            // max $10.00 per day total
  asset: 'USDC',
  issuer: USDC_ISSUER.testnet,
}, ownerKeypair)

console.log(`Policy created: ${policyId}`)

Section 5 — Executing an Autonomous Payment

ts
// The AGENT signs this — not the owner
const record = await mind.policy.executePayment({
  policyId: 1n,
  recipient: 'GXXXRECIPIENT...',
  amount: '0.01',
  memo: 'Payment for image generation job #8821',
}, agentKeypair)

console.log(`Paid ${record.amount} on ledger ${record.ledger}`)

Section 6 — Checking Remaining Allowance

tsconst remaining = await mind.policy.remainingAllowanceDisplay(1n)
console.log(remaining) // "8.5000000 USDC"

Section 7 — Error Handling

tsimport { StellarMindError, ErrorCodes } from '@stellarmind/sdk'

try {
  const agent = await mind.registry.getAgent('unknown-id')
} catch (err) {
  if (err instanceof StellarMindError) {
    switch (err.code) {
      case ErrorCodes.AGENT_NOT_FOUND:
        console.log('Agent does not exist')
        break
      case ErrorCodes.NETWORK_ERROR:
        console.log('Could not reach Stellar RPC:', err.message)
        break
      case ErrorCodes.EXCEEDS_DAILY_LIMIT:
        console.log('Daily spending limit reached')
        break
    }
  }
}

Section 8 — Network Configuration

ts
// Testnet (default for development)
const mind = new StellarMind({ network: 'testnet' })

// Mainnet (production)
const mind = new StellarMind({ network: 'mainnet' })

// Custom RPC URL
const mind = new StellarMind({
  network: 'testnet',
  rpcUrl: 'https://my-custom-rpc.example.com',
})

Section 9 — TypeScript Types Reference

List all exported types with a one-line description each:

Agent — full agent struct returned from registry
SpendingPolicy — full policy struct
RegisterAgentParams — input for registry.register()
CreatePolicyParams — input for policy.create()
ExecutePaymentParams — input for policy.executePayment()
PaymentRecord — returned from executePayment()
StellarMindConfig — SDK constructor config
Network — 'mainnet' | 'testnet' | 'futurenet'

Acceptance Criteria

File docs/SDK_GUIDE.md created
All 9 sections present
Every code example is syntactically correct TypeScript (no fake syntax)
Import statements are accurate and match what sdk/src/index.ts actually exports
All USDC_ISSUER references use the correct exported constant
No placeholder text like "TODO" or "coming soon" left in the guide
The guide reads clearly for a developer who has never used StellarMind before

Tips

Read sdk/src/index.ts to see exactly what is exported — only document real exports
Read sdk/src/types.ts for the full list of types
Test every code snippet mentally — if it would throw a TypeScript error, fix it

Estimated Effort
Small (2–4 hours)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions