npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

grid-sdk

v1.0.5

Published

Grid SDK for web and React Native

Readme

Grid SDK

A unified TypeScript SDK for integrating Grid smart accounts into React applications.

Installation

npm install grid-sdk
# or
yarn add grid-sdk

Quick Start

import { GridClient } from "grid-sdk";

const gridClient = new GridClient({
  environment: "sandbox", 
  apiKey: <GRID_API_KEY>
});

Noop Transaction Demo

import { GridClient, PrepareArbitraryTransactionRequest } from "grid-sdk";
import { getGridApiKey } from "../../common/config";
import { LocalState } from "../utils/state";
import { TransactionMessage,Keypair,Connection,Transaction,SystemProgram,PublicKey,VersionedTransaction,LAMPORTS_PER_SOL, TransactionInstruction } from "@solana/web3.js";


/*
    Step 1: Initialize the account creation
*/
async function createAccount(){
    const gridClient = new GridClient({environment: "sandbox", apiKey: getGridApiKey()});

    const user = await gridClient.createAccount({
        email: '[email protected]'
    });

    const context = gridClient.getContext();
   
    LocalState.saveState("context", context);
    LocalState.saveState("user", user);
}

/*
    Step 2: Finish the account creation and send a noop transaction
*/
async function verifyAndSendTransaction(){
    const context = LocalState.loadState("context");
    const user = LocalState.loadState("user");

    // Recreate GridClient instance from saved context configuration
    const gridClient = new GridClient({
        environment: context.client.environment,
        apiKey: context.client.config.apiKey
    });

    const sessionSecrets = await gridClient.generateSessionSecrets();

    // OTP goes here
    const payload = {
        user: user,
        otpCode: `<YOUR OTP CODE>`,
        sessionSecrets
    }

    const resp = await gridClient.completeAuthAndCreateAccount(payload);
    const accountData = resp.data;

    // Create a noop transaction
    const noopProgramId = new PublicKey(
        "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"
    );

    const ix = new TransactionInstruction({
        programId: noopProgramId,
        keys: [],
        data: Buffer.alloc(0),
    });

    const connection = new Connection("https://api.devnet.solana.com")
    const {blockhash, lastValidBlockHeight} = await connection.getLatestBlockhash('confirmed');

    // User's smart account public key
    const saPublicKey = accountData.address;

    const messageV0 = new TransactionMessage({
        payerKey: new PublicKey(saPublicKey),
        recentBlockhash: blockhash,
        instructions: [ix],
    }).compileToV0Message();

    // Create a versioned transaction
    const transaction = new VersionedTransaction(messageV0);

    // Serialize and encode the transaction
    const serializedTransaction = transaction.serialize();

    const encodedTransaction = Buffer.from(serializedTransaction).toString('base64');


    const noopTransactionPayload = {
        transaction: encodedTransaction,
    } as PrepareArbitraryTransactionRequest;

    const transactionPayload = await gridClient.prepareArbitraryTransaction(accountData.address, noopTransactionPayload);

    if (!transactionPayload) {
        throw new Error('Failed to create prepare noop txn: ' + JSON.stringify(transactionPayload));
    }

    const signature = await gridClient.signAndSend({
        sessionSecrets: sessionSecrets,
        session: accountData.authentication,
        transactionPayload: transactionPayload.data!,
        address: accountData.address
    })

    console.log('signature: ', signature);
}



/*
 USE THIS TO FOLLOW STEPS 1 AND 2
*/
if (require.main === module) {
    createAccount();  
    //verifyAndSendTransaction();
}

Core Features

Create Account / Register

With Email

import { GridClient } from "grid-sdk";


const gridClient = new GridClient({environment: "sandbox", apiKey: <GRID_API_KEY>});

const user = await gridClient.createAccount({
    email: '[email protected]'
});

With Signer

import { GridClient } from "grid-sdk";


const gridClient = new GridClient({environment: "sandbox", apiKey: <GRID_API_KEY>});

const user = await gridClient.createAccount({
    signer: 'EYWVR63HFn6xx3j2bEepyTFqhxjuPnxag5G5RYvHX7AT'
});

Generate Session Secrets

const sessionSecrets = await gridClient.generateSessionSecrets();

Output:

[
  {
    publicKey: 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeO4soENGrx3ejRgeBO2dbLhhPeX5c9rZl9KXwczUy0N7PFKAL0tHj9JpTqQ0SEN5zaS3OtBgLZia2vINpMmJbA==',
    privateKey: 'MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgAZLliZoAbIxI2qvmHmPRHC9MmzmnZ11nlcGoOqoJ5s6hRANCAAR47iygQ0avHd6NGB4E7Z1suGE95flz2tmX0pfBzNTLQ3s8UoAvS0eP0mlOpDRIQ3nNpLc60GAtmJra8g2kyYls',
    provider: 'privy',
    tag: 'primary'
  },
  {
    publicKey: '0225d0c8d7b77cac0df8ad6d3c1d798114347eb8ff8306ba147f55461b7815285d',
    privateKey: '862cd16fd0cc7e0b26a1bbe18a6bf3985b78f71124a681650070931d8190ddb3',
    provider: 'turnkey',
    tag: 'backup'
  },
  {
    publicKey: 'AtZ6PW4hMBriwAmcBw3kuVS91nxn1WHTZqzMhrL9NfF3',
    privateKey: 'pQRc9u87K52Pb1EvhZHw5XKfyK7l8Y4ZNiOTKz72NJqS7hdVyuaeLROFz28jS62Yn4afqyR5mtUUGh6sH9Qzbg==',
    provider: 'solana',
    tag: 'solana'
  },
  {
    publicKey: 'CsEqNuFKauRcK6uTKsdfMsKWPoo6oha8TPhi2qZxHYNh',
    privateKey: 'eABAQmT/HVzooFuKpgD0PmRsk/q+oOx1XvHicnymRJqwTz0o+XWMaso6QW26LS6D/nlGbX4TZbo2UqUnDRcItg==',
    provider: 'passkey',
    tag: 'passkey'
  }
]

Authentication Flow

Verify and Create Account (Email Only)

const sessionSecrets = await gridClient.generateSessionSecrets();

// save sessionSecrets

const context = gridClient.getContext(); 

const payload = {
    user: context.user, 
    otpCode: '625932',
    sessionSecrets
}

const result = await gridClient.completeAuthAndCreateAccount(payload);
console.log("user:", result.data);

Verify (No Account Creation)

const sessionSecrets = await gridClient.generateSessionSecrets();

// save sessionSecrets

const context = gridClient.getContext(); 
   
const payload = {
    user: user,
    otpCode: '591977',
    sessionSecrets
}

const result = await gridClient.completeAuth(payload);

console.log("user: ", result.data);;

Sign Transactions

// Step 1: Create spending limit 
const spendingLimitPayload = {
    amount: 100000,
    mint: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
    spending_limit_signers: ["7kEydiJ9en86ESNpwpZ45khxX8usgjUmWxbSTzkSbXkR"],
    period: "one_time",
    destinations: ["3ciascNndLTBrDQXvs8nzZgWAiaL33tGM6fx3zzM7Fxt"]
} as SpendingLimitRequest;

const spendingLimitResult = await gridClient.createSpendingLimit(user.address, spendingLimitPayload);

// Step 2: Sign transaction
const signature = await gridClient.signAndSend({
    sessionSecrets: keypairs,
    session: user.authentication,
    transactionPayload: spendingLimitResult.data,
    address: accountAddress
})

console.log('signature: ', signature);

API Reference

Key Methods

  • createAccount(input) - Create a new Grid account
  • generateSessionSecrets() - Generate keypairs for all supported providers
  • initAuth(request) - Initialize authentication flow
  • completeAuth(request) - Complete authentication with OTP
  • completeAuthAndCreateAccount(request) - Complete auth and create account
  • sign(request) - Sign a transaction
  • send(request) - Submit a signed transaction
  • getContext() - Get current client context
  • createSpendingLimit(address, request) - Set spending limits
  • getAccount(address) - Get account details
  • getAccountBalances(address) - Get account balances