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

escrow-market-sdk

v0.1.6

Published

SDK for Escrow Market Solana Program

Readme

Escrow Market SDK

SDK for the Escrow Market program on the Solana blockchain.

Installation

npm install escrow-market-sdk

or

yarn add escrow-market-sdk

SDK Structure

The SDK is organized into the following modules:

  • EscrowMarketClient: The main class for interacting with the program
  • Types: Interfaces and types for accounts, instructions, and events
  • Utils: Utility functions for finding PDAs, data type conversions, etc.
  • Constants: Constants used in the program

Basic Usage

import { Connection, Keypair, PublicKey, sendAndConfirmTransaction } from '@solana/web3.js';
import { EscrowMarketClient } from 'escrow-market-sdk';

// Connect to Solana cluster
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');

// Initialize client with program ID
const programId = 'your_program_id_here'; // Program ID as string
const client = new EscrowMarketClient(connection, programId);

// Send a transaction with your keypair
const tx = await client.someMethod(...);
const signature = await sendAndConfirmTransaction(connection, tx, [yourKeypair]);

Main Functions

1. Initialize

Initialize the Config account for the escrow market:

const admin = new PublicKey('...');
const operator = new PublicKey('...');

// Creates transaction object that needs to be signed and sent
const tx = await client.initialize(feePayer, admin, operator);
const signature = await sendAndConfirmTransaction(connection, tx, [feePayerKeypair]);
console.log(`Initialize successful: ${signature}`);

2. Initialize Vault

Initialize a vault for a mint:

const mint = new PublicKey('...');

// Creates transaction object that needs to be signed and sent
const tx = await client.initializeVault(feePayer, mint);
const signature = await sendAndConfirmTransaction(connection, tx, [feePayerKeypair]);
console.log(`Initialize vault successful: ${signature}`);

3. Deposit

Deposit tokens into the vault:

const mint = new PublicKey('...');
const amount = 1_000_000; // 1 token with 6 decimals

// Creates transaction object that needs to be signed and sent
const tx = await client.deposit(depositor, mint, amount);
const signature = await sendAndConfirmTransaction(connection, tx, [depositorKeypair]);
console.log(`Deposit successful: ${signature}`);

4. Withdraw

Withdraw tokens from the vault:

const mint = new PublicKey('...');
const amount = 1_000_000; // 1 token with 6 decimals
const nonce = 123456; // Unique nonce to prevent replay attacks

// Creates transaction object that needs to be signed and sent
const tx = await client.withdraw(operatorPubkey, user, mint, amount, nonce);
const signature = await sendAndConfirmTransaction(connection, tx, [operatorKeypair]);
console.log(`Withdraw successful: ${signature}`);

5. Settle

Complete a deal:

const dealId = 'deal-123';
const buyer = new PublicKey('...');
const seller = new PublicKey('...');
const tokenTransfer = new PublicKey('...');  // Token being transferred from seller to buyer
const tokenWithdraw = new PublicKey('...');  // Token being withdrawn from vault to seller
const transferAmount = 1_000_000;  // Amount of tokenTransfer
const withdrawAmount = 2_000_000;  // Amount of tokenWithdraw

// Creates transaction object that needs to be signed and sent
const tx = await client.settle(
  operatorPubkey,
  dealId,
  buyer,
  seller,
  tokenTransfer,
  tokenWithdraw,
  transferAmount,
  withdrawAmount
);
const signature = await sendAndConfirmTransaction(connection, tx, [operatorKeypair]);
console.log(`Settle successful: ${signature}`);

6. Operator Cancel

Cancel a deal by the operator:

const dealId = 'deal-123';
const buyer = new PublicKey('...');
const tokenWithdraw = new PublicKey('...');
const amount = 1_000_000;

// Creates transaction object that needs to be signed and sent
const tx = await client.operatorCancel(
  operatorPubkey,
  dealId,
  buyer,
  tokenWithdraw,
  amount
);
const signature = await sendAndConfirmTransaction(connection, tx, [operatorKeypair]);
console.log(`Cancel successful: ${signature}`);

7. Parse Events

Parse events from a transaction:

const signature = "..."; // Transaction signature

const events = await client.parseEventsFromTransaction(signature);
console.log('Events:', events);

8. Get Information

// Get config
const config = await client.getConfig();
console.log('Config:', config);

// Get deal information
const dealId = 'deal-123';
const deal = await client.getDeal(dealId);
console.log('Deal:', deal);

// Get vault balance
const mint = new PublicKey('...');
const balance = await client.getVaultBalance(mint);
console.log(`Vault balance: ${balance}`);

9. Subscribe to Events

// Register event listener
const listenerId = client.subscribeToEvents('SettleEvent', (event) => {
  console.log('Settle event:', event);
});

// Unsubscribe
await client.unsubscribeFromEvent(listenerId);

Examples

The SDK comes with examples to help you get started.

Development Notes

  1. PDA Management: Make sure you use the correct seeds for PDAs when interacting with the program.
  2. Error Handling: Always wrap function calls in try/catch blocks to handle errors.
  3. Token Balance: Check token balances before performing deposit, withdraw, or settle transactions.
  4. Permissions: Only the admin can initialize the program, and only the operator can cancel deals.
  5. Token Programs: The SDK supports both standard SPL tokens and custom token programs.

License

MIT