SIMA

SDK Examples

Public SDK examples for the production purchase flow.

OpenAPI-aligned examples using @sima-prime/agent-sdk 0.2.0 — offer → purchase → payment-intent → confirm-payment.

Install SDK

npm install @sima-prime/agent-sdk
# https://github.com/Mustafashehab/SIMA-Agent-SDK

Initialize SDK

import { SimaAgentClient } from "@sima-prime/agent-sdk";

const client = new SimaAgentClient({
  apiBaseUrl: "https://api.sima-prime.com",
});

Authenticate Wallet

const nonce = await client.requestWalletNonce("YOUR_WALLET_ADDRESS");
// Sign nonce.message outside SIMA, then:
const session = await client.verifyWalletSignature({
  chain: "SOLANA",
  walletAddress: "YOUR_WALLET_ADDRESS",
  message: nonce.message,
  signature: "YOUR_SIGNATURE",
});
client.setAccessToken(session.accessToken);

Request Offer

const offer = await client.getProtectionOffer({
  chain: "SOLANA",
  walletAddress: "YOUR_WALLET_ADDRESS",
  assetAddress: "TOKEN_ADDRESS",
  assetSymbol: "TOKEN",
  assetType: "TOKEN",
  protectedAmount: "1000",
});

Purchase and activate

const purchase = await client.purchaseProtection({
  ...offer,
  offerId: offer.offerId,
  protectionDecision: "PURCHASE_PROTECTION",
});
const intent = await client.getPurchasePaymentIntent(purchase.certificateId);
// Send SOL on-chain, then:
await client.confirmPurchasePayment(purchase.certificateId, {
  paymentReference: intent.paymentReference,
  transactionSignature: "YOUR_ON_CHAIN_SIGNATURE",
});