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

mcswap-sdk

v0.6.8

Published

Javascript SDK for the McSwap Protocol

Readme

mcswap-sdk

Javascript SDK for the McSwap Protocol

McSwap is a Trustless Smart Escrow Protocol on the Solana Blockchain that enables app developers to build their own Marketplace and OTC/P2P services for digital assets. Onchain revenue sharing is built-in and allows developers to define usage fees for when they or their application's users create or execute McSwap Escrows through their apps and tools.

powered by solana

Install

npm i mcswap-sdk

Import

import mcswap from 'mcswap-sdk';

Methods

mcswap-spl

mcswap.splCreate
mcswap.splExecute
mcswap.splCancel
mcswap.splReceived
mcswap.splSent

mcswap-core

mcswap.coreCreate
mcswap.coreCancel
mcswap.coreExecute
mcswap.coreReceived
mcswap.coreSent

mcswap-nft

mcswap.nftCreate
mcswap.nftCancel
mcswap.nftExecute
mcswap.nftReceived
mcswap.nftSent

mcswap-pnft

mcswap.pnftCreate
mcswap.pnftCancel
mcswap.pnftExecute
mcswap.pnftReceived
mcswap.pnftSent

mcswap-cnft

mcswap.cnftCreate
mcswap.cnftCancel
mcswap.cnftExecute
mcswap.cnftReceived
mcswap.cnftSent

helpers

mcswap.find
mcswap.fetch
mcswap.fee

utilities

mcswap.send
mcswap.status

Examples

example setup

import { Keypair } from "@solana/web3.js";
const rpc = "https://staked.helius-rpc.com?api-key=YOUR-KEY";
const secret = [1,2,3,4,5,~];
const signer = Keypair.fromSecretKey(new Uint8Array(secret));

mcswap-spl

splCreate Escrow

const tx = await mcswap.splCreate({
    rpc: rpc,
    builder: true, // builder false will return ix for tx only
    blink: false, // blink true will return a base64 formatted object
    tolerance: 1.2, // cu estimate multiplier for padding if needed
    priority: "Medium", // priority fee level
    convert: true, // convert true because we're passing decimal values for amounts below
    affiliateWallet: "ACgZcmgmAnMDxXxZUo9Zwg2PS6WQLXy63JnnLmJFYxZZ",
    affiliateFee: "0.0009",
    seller: "7Z3LJB2rxV4LiRBwgwTcufAWxnFTVJpcoCMiCo8Z5Ere", // provider
    token1Mint: "So11111111111111111111111111111111111111112",
    token1Amount: "0.001",
    token2Mint: false,
    token2Amount: false,
    buyer: false, // buyer false makes this a public listing
    token3Mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    token3Amount: "0.003",
    token4Mint: false,
    token4Amount: false,
    physical: 0, // 0 = Digital, 1 = Phygital + Shipping, 2 = Phygital Pick-Up, 
    memo: "", // optional title or reference number
});
if(tx.tx){
    tx.tx.sign([signer]);
    const signature = await mcswap.send(rpc,tx.tx);
    console.log("signature", signature);
    console.log("awaiting status...");
    const status = await mcswap.status(rpc,signature);
    if(status!="finalized"){console.log(status);}
    else{
        console.log(status);
        const escrow = await mcswap.fetch({
            rpc:rpc, display:true, standard:"spl", escrow:tx.escrow
        });
        console.log(escrow);
    }
}
else{
    console.log(tx);
}

splCancel Escrow

const tx = await mcswap.splCancel({
    rpc: rpc,
    escrow: "2jcih7dUFmEQfMUXQQnL2Fkq9zMqj4jwpHqvRVe3gGLL" // escrow id (acct)
});
if(typeof tx.status!="undefined"){console.log(tx);}
else{
    tx.sign([signer]);
    const signature = await mcswap.send(rpc,tx);
    console.log("signature", signature);
    console.log("awaiting status...");
    const status = await mcswap.status(rpc,signature);
    console.log(status);
}

splExecute Escrow

const tx = await mcswap.splExecute({
    rpc: rpc,
    convert: true,
    affiliateWallet: "ACgZcmgmAnMDxXxZUo9Zwg2PS6WQLXy63JnnLmJFYxZZ",
    affiliateFee: "0.0009",
    escrow: "3pjxfm25WWwD9BcWSqBFamJKYgEpNAnEz8mEmxk9biBQ",
    buyer: "2jcih7dUFmEQfMUXQQnL2Fkq9zMqj4jwpHqvRVe3gGLL",
    memo: "Optional Memo Man!"
});
if(typeof tx.status!="undefined"){console.log(tx);}
else{
    tx.sign([signer]);
    const signature = await mcswap.send(rpc,tx);
    console.log("signature", signature);
    console.log("awaiting status...");
    const status = await mcswap.status(rpc,signature);
    console.log(status);
}

splReceived Escrows

const splReceived = await mcswap.splReceived({
    rpc: rpc,
    display: true,
    wallet: "2jcih7dUFmEQfMUXQQnL2Fkq9zMqj4jwpHqvRVe3gGLL"
});
console.log(splReceived);

splSent Escrows

const splSent = await mcswap.splSent({
    rpc: rpc,
    display: true,
    private: false, // (default) private false returns public listings
    wallet: "7Z3LJB2rxV4LiRBwgwTcufAWxnFTVJpcoCMiCo8Z5Ere"
});
console.log(splSent);

all public spl escrows

warning, this can be rpc intensive

const splPublic = await mcswap.splSent({
    rpc: rpc,
    display: true,
    private: false,
    wallet: false
});
console.log(splPublic);

mcswap-nft

nftCreate, pnftCreate, cnftCreate, coreCreate

const tx = await mcswap.nftCreate({
    rpc: rpc,
    builder: true,
    blink: false,
    convert: true,
    tolerance: 1.2,
    priority: "Medium",
    affiliateWallet: "ACgZcmgmAnMDxXxZUo9Zwg2PS6WQLXy63JnnLmJFYxZZ",
    affiliateFee: "0.0009",
    seller: "7Z3LJB2rxV4LiRBwgwTcufAWxnFTVJpcoCMiCo8Z5Ere",
    sellerMint: "5Jk6hn3rR1DJjtDU4MzgDuN3SXH4nfHiYgqmEVhGyEUt",
    buyer: false, // buyer false makes this a public listing
    buyerMint: false,
    lamports: "0.0001",
    tokenMint: "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",
    units: "0.01",
    physical: 0, // 0 = Digital, 1 = Phygital + Shipping, 2 = Phygital Pick-Up, 
    sellerEmail: "[email protected]", // add if physical > 0
});
if(tx.status){console.log(tx);}
else{
    tx.sign([signer]);
    const signature = await mcswap.send(rpc,tx);
    console.log("signature", signature);
    console.log("awaiting status...");
    const status = await mcswap.status(rpc,signature);
    if(status!="finalized"){console.log("status", status);}
    else{
        console.log(status);
    }
}

nftCancel, pnftCancel, cnftCancel, coreCancel

const tx = await mcswap.nftCancel({
    rpc: rpc,
    blink: false,
    sellerMint: "5Jk6hn3rR1DJjtDU4MzgDuN3SXH4nfHiYgqmEVhGyEUt",
    buyerMint: false,
});
if(tx.status){console.log(tx);}
else{
    tx.sign([signer]);
    const signature = await mcswap.send(rpc,tx);
    console.log("signature", signature);
    console.log("awaiting status...");
    const status = await mcswap.status(rpc,signature);
    console.log(status);
}

nftExecute, pnftExecute, cnftExecute, coreExecute

const tx = await mcswap.nftExecute({
    rpc: rpc,
    blink: false,
    convert: true,
    tolerance: 1.2,
    priority: "Medium",
    affiliateWallet: "ACgZcmgmAnMDxXxZUo9Zwg2PS6WQLXy63JnnLmJFYxZZ",
    affiliateFee: "0.0009",
    buyer: "2jcih7dUFmEQfMUXQQnL2Fkq9zMqj4jwpHqvRVe3gGLL",
    sellerMint: "5Jk6hn3rR1DJjtDU4MzgDuN3SXH4nfHiYgqmEVhGyEUt",
    buyerMint: false,
    memo: "Awesome Memo Man!"
});
if(tx.status){console.log(tx);}
else{
    tx.sign([signer]);
    const signature = await mcswap.send(rpc,tx);
    console.log("signature", signature);
    console.log("awaiting status...");
    const status = await mcswap.status(rpc,signature);
    console.log(status);
}

nftReceived, pnftReceived, cnftReceived, coreReceived

const nftReceived = await mcswap.nftReceived({
    rpc: rpc,
    display: true,
    wallet: "2jcih7dUFmEQfMUXQQnL2Fkq9zMqj4jwpHqvRVe3gGLL"
});
console.log(nftReceived);

nftSent, pnftSent, cnftSent, coreSent

const nftSent = await mcswap.nftSent({
    rpc: rpc,
    display: true,
    private: false, // private false returns public listings by default
    wallet: "7Z3LJB2rxV4LiRBwgwTcufAWxnFTVJpcoCMiCo8Z5Ere"
});
console.log(nftSent);

Helpers

sns

accepts the data object passed to the parent method returns the object with seller and buyer .sol addresses converted

_data_ = await mcswap.sns(connection, _data_);

find escrow id

returns an escrow id or false

const escrow = await mcswap.find({
    rpc: rpc,
    standard: "core",
    seller: "7Z3LJB2rxV4LiRBwgwTcufAWxnFTVJpcoCMiCo8Z5Ere",
    mint: "35rxoAdMJXm6cSSEpQ25qgmLFjhShpsEMc3guQjeZva8",
    private: false,
});
console.log(escrow);
// response: DUjEPTHQsUizXcyfix5iEnxvU6vMxU6EJW4FEHs9Xgrb

fetch escrow details

returns an escrow's details

const details = await mcswap.fetch({
    rpc: rpc,
    display: true,
    standard: "core",
    escrow: "DUjEPTHQsUizXcyfix5iEnxvU6vMxU6EJW4FEHs9Xgrb",
});
console.log(details);

get base fee

get the base escrow fee for the standard

const fee = await mcswap.fee({
    rpc: rpc, 
    display: true, // true = sol, false = lamports
    standard: "nft" // spl, nft, pnft, cnft, core
});
console.log(fee);