Server-Side Integration with Node.js

Server-side StarkNet integration with ChipiServerSDK for Node.js. Wallet operations, transfers, session key lifecycle, and SKU purchases from Express, Fastify, or Hono.

Overview

The @chipi-stack/backend package provides ChipiServerSDK for server-side StarkNet operations. Use it with Express, Fastify, Hono, or any Node.js server to create wallets, execute transfers, manage session key lifecycles, and purchase digital services. All transactions are gasless.

Install

Install the Chipi backend SDK:

bashnpm install @chipi-stack/backend@latest

Requires Node.js 18+.

Authentication

Initialize the server SDK with both public and secret keys:

typescriptimport { ChipiServerSDK } from "@chipi-stack/backend";

const serverClient = new ChipiServerSDK({
  publicKey: "pk_prod_YOUR_KEY",
  secretKey: "sk_prod_YOUR_KEY",
});

The server SDK uses both keys for full access to all operations. Never expose sk_prod_ keys to client code.

Wallet Operations

Create a wallet for an authenticated user:

typescriptconst result = await serverClient.createWallet({
  externalUserId: "user_123",
  chain: "STARKNET",
  walletType: "CHIPI",
  encryptKey: "user-passkey-or-pin",
});
console.log(result.publicKey, result.txHash);

Get an existing wallet:

typescriptconst wallet = await serverClient.getWallet({ externalUserId: "user_123" });

Transfers

Transfer tokens server-side:

typescriptconst result = await serverClient.transfer({
  encryptKey: "user-passkey-or-pin",
  walletPublicKey: "0x...",
  token: "USDC",
  recipient: "0x...",
  amount: "10",
  chain: "STARKNET",
});
console.log(result.txHash);

Use human-readable amounts. The SDK handles decimal conversion. USDC has 6 decimals, ETH/STRK have 18.

Session Keys: Full Lifecycle

Session keys let you execute multiple transactions without requiring user authentication each time. The full lifecycle:

typescript// 1. Create session keypair (local. No on-chain tx)
const session = await serverClient.createSession({
  walletPublicKey: "0x...",
});

// 2. Register session on-chain (requires owner auth)
await serverClient.registerSession({
  encryptKey: "user-passkey-or-pin",
  walletPublicKey: "0x...",
  sessionPublicKey: session.publicKey,
});

// 3. Execute with session (no auth needed per tx)
await serverClient.executeWithSession({
  sessionPrivateKey: session.privateKey,
  walletPublicKey: "0x...",
  calls: [{
    contractAddress: "0x...",
    entrypoint: "transfer",
    calldata: ["0x_RECIPIENT", "10000000", "0"],
  }],
});

// 4. Revoke session on logout
await serverClient.revokeSession({
  walletPublicKey: "0x...",
  sessionPublicKey: session.publicKey,
});

Session keys require walletType: "CHIPI". They do not work with READY (Argent X) wallets.

SKU Purchases and Key Details

Purchase digital services (Mexico only):

typescriptconst result = await serverClient.purchaseSku({
  encryptKey: "user-passkey-or-pin",
  walletPublicKey: "0x...",
  skuId: "sku_123",
  reference: "5551234567",
  amount: "10",
});

Key details:

  • - Server-side only. Uses both public and secret keys
  • - All transactions gasless through Chipi
  • - Works with Express, Fastify, Hono, or any Node.js server
  • - Session keys require CHIPI wallet type
  • - API rate limit: 100 requests/minute

Ready to build?

Connect the Chipi MCP server and start building in minutes.

Get Started