Grid Stablecoin Accounts make it simple to build modern fintech applications with email-based onboarding, programmable spending limits, and sub-penny transaction costs. This guide will get you up and running in minutes.
Grid Stablecoin Accounts currently support any Solana token and are compatible with Solana-based programs, providing a powerful base for composability.

Get API Keys

Before you can start building, you’ll need API credentials from the Grid dashboard.

Get API Keys

Visit the Grid dashboard to generate your sandbox and production API keys
Keep your API keys secure and never expose them in client-side code. Always use environment variables or secure key management systems.

Prerequisites

Before integrating Grid Stablecoin Accounts, ensure you have:
  • Node.js 18+ or another runtime environment
  • API credentials from the Grid dashboard
  • Basic understanding of REST APIs and async/await patterns

SDK Installation

Install the official Grid SDK to get started quickly:
npm install grid-sdk
The Grid SDK provides TypeScript support out of the box and handles authentication, error handling, and API communication automatically.

Grid SDK Documentation

View complete SDK documentation, API reference, and additional examples on NPM

SDK Initialization

Set up your Grid client using the official SDK:
import { GridClient } from "grid-sdk";

// Initialize the Grid client
const gridClient = new GridClient({
  environment: "sandbox", // Use 'production' for live applications
  apiKey: process.env.GRID_API_KEY!, // Your API key from the dashboard
});

// Verify the connection
console.log("Grid client initialized successfully");
The Grid SDK automatically handles API authentication, request retries, and error formatting. You don’t need to build your own HTTP client.

Complete Integration Example

Complete workflow from account creation through transaction execution:
1

Initialize Grid Client

Set up your Grid SDK client with API credentials:
import { GridClient } from 'grid-sdk';

const gridClient = new GridClient({
  environment: 'sandbox', // Use 'production' for live applications
  apiKey: process.env.GRID_API_KEY!,
});
2

Generate Session Secrets

Create cryptographic keypairs that will authorize all future transactions:
const sessionSecrets = await gridClient.generateSessionSecrets();
console.log('Session secrets generated - these contain private keys needed for signing!');
Session secrets contain private keys that enable transaction signing. Store them encrypted and never expose them in client-side code.
3

Create Email Account

Create a new Grid account using email-based onboarding:
const accountData = await gridClient.createAccount({
  email: 'user@example.com',
});
console.log('Account created:', accountData.address);
console.log('OTP sent to email for verification');
4

Verify Account with OTP

Complete account verification using the OTP sent to the user’s email:
const verifiedAccount = await gridClient.completeAuth({
  address: accountData.address,
  otp_code: '123456', // User receives this via email
});
console.log('Account verified successfully');
5

Prepare Transaction

Before executing, prepare the transaction payload using the SDK:
const rawTransactionPayload = {
  transaction: "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArc20SI/X2z8FPQhKgWWbWfXOTI3TDjuQQB8JfpF+1e4u3shfDGrJc7jvYd11DguvNKYg2PsUz7b7GZKwcAjMBoCAAECAAkDAAAAAMOhGsIAAAAA", // Your Solana transaction
  transaction_signers: [accountData.address] // Optional: only needed when signing with local signers
};

// Prepare the transaction payload
const transactionPayload = await gridClient.prepareArbitraryTransaction(
  accountData.address,
  rawTransactionPayload
);
console.log('Transaction prepared successfully');
The transaction_signers field is optional and only required when you need to sign the transaction with additional local signers alongside Grid’s signing.
6

Execute Transactions

Use the signAndSend method to execute the prepared transaction:
const executedTx = await gridClient.signAndSend({
  sessionSecrets, // Private keys for cryptographic signing
  session: verifiedAccount, // Authenticated account session
  transactionPayload, // Prepared transaction payload
  address: accountData.address
});
console.log('Transaction executed:', executedTx.signature);
The signAndSend method handles both cryptographic signing and network submission in a single call, simplifying transaction execution.
For production applications, implement proper error handling, retry logic, and secure secret management around each of these steps.
Ready to go live? Make sure to update your API endpoints to production URLs and use your production API keys. Grid provides the same API structure across sandbox and production environments.