New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

solana-stablecoin-standard

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

solana-stablecoin-standard

TypeScript SDK for the Solana Stablecoin Standard (SSS) — mint, burn, blacklist, seize, freeze, oracle, and GENIUS Act compliance

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

solana-stablecoin-standard

TypeScript SDK for the Solana Stablecoin Standard (SSS). Provides a high-level client for interacting with both the sss-token and sss-transfer-hook programs, PDA derivation helpers, event parsing, oracle integration, and preset configuration utilities.

Installation

npm install solana-stablecoin-standard

Peer dependencies: @solana/web3.js (^1.95), @coral-xyz/anchor (^0.31.1), @solana/spl-token (^0.4), bn.js (^5.2).

Quick Start

import { Connection, Keypair } from "@solana/web3.js";
import { Wallet, BN } from "@coral-xyz/anchor";
import { SSSClient, StablecoinPreset, getPresetAnchorEnum } from "solana-stablecoin-standard";

// Connect
const connection = new Connection("http://localhost:8899", "confirmed");
const wallet = new Wallet(Keypair.generate());
const client = new SSSClient(connection, wallet);

// Initialize an SSS-2 compliant stablecoin
const mintKeypair = Keypair.generate();
const { signature } = await client.initialize(
  {
    name: "USD Coin",
    symbol: "USDC",
    uri: "https://example.com/metadata.json",
    decimals: 6,
    preset: getPresetAnchorEnum(StablecoinPreset.SSS2),
  },
  mintKeypair,
  client.hookProgramId // pass hook program for SSS-2
);
console.log("Initialized:", signature);

// Configure a minter
await client.updateMinter(
  mintKeypair.publicKey,
  wallet.publicKey,
  { isActive: true, mintQuota: new BN(1_000_000_000) }
);

// Mint tokens
const recipientATA = client.getAssociatedTokenAddress(
  mintKeypair.publicKey,
  wallet.publicKey
);
await client.mintTokens(mintKeypair.publicKey, new BN(500_000_000), recipientATA);

// Fetch config
const config = await client.fetchConfig(mintKeypair.publicKey);
console.log("Total minted:", config.totalMinted.toString());

API Reference

Constructor

new SSSClient(connection: Connection, wallet: Wallet, options?: SSSClientOptions)
OptionTypeDefaultDescription
tokenProgramIdPublicKeySSS_TOKEN_PROGRAM_IDOverride the sss-token program ID
hookProgramIdPublicKeySSS_TRANSFER_HOOK_PROGRAM_IDOverride the sss-transfer-hook program ID

PDA Helpers

All PDA helpers are available both as instance methods on SSSClient and as standalone functions.

MethodParametersReturnsDescription
getConfigPdamint: PublicKey[PublicKey, number]Derive the StablecoinConfig PDA for a mint
getRoleRegistryPdaconfig: PublicKey[PublicKey, number]Derive the RoleRegistry PDA
getMinterInfoPdaconfig: PublicKey, minter: PublicKey[PublicKey, number]Derive the MinterInfo PDA for a specific minter wallet
getBlacklistPdaconfig: PublicKey, address: PublicKey[PublicKey, number]Derive the BlacklistEntry PDA for a specific address
getReserveAttestationPdaconfig: PublicKey, index: BN | number[PublicKey, number]Derive the ReserveAttestation PDA by index
getExtraAccountMetaListPdamint: PublicKey[PublicKey, number]Derive the ExtraAccountMetaList PDA (hook program)

Account Fetchers

MethodParametersReturnsDescription
fetchConfigmint: PublicKeyPromise<StablecoinConfig>Fetch the StablecoinConfig account
fetchRoleRegistryconfig: PublicKeyPromise<RoleRegistry>Fetch the RoleRegistry account
fetchMinterInfoconfig: PublicKey, minter: PublicKeyPromise<MinterInfo>Fetch a MinterInfo account
fetchBlacklistEntryconfig: PublicKey, address: PublicKeyPromise<BlacklistEntry | null>Fetch a BlacklistEntry or null if not blacklisted
fetchReserveAttestationconfig: PublicKey, index: BN | numberPromise<ReserveAttestation>Fetch a ReserveAttestation by index

Instructions

All instruction methods return Promise<{ signature: string }>.

MethodParametersDescription
initializeparams: InitializeParams, mintKeypair: Keypair, hookProgramId?: PublicKeyInitialize a new stablecoin. Pass hookProgramId for SSS-2.
mintTokensmint: PublicKey, amount: BN, recipientTokenAccount: PublicKeyMint tokens. Caller must be an active minter with sufficient quota.
burnTokensmint: PublicKey, amount: BN, burnerTokenAccount: PublicKeyBurn tokens from the caller's token account.
freezeAccountmint: PublicKey, targetTokenAccount: PublicKeyFreeze a token account. Requires master authority or pauser role.
thawAccountmint: PublicKey, targetTokenAccount: PublicKeyThaw a frozen token account. Requires master authority or pauser role.
pausemint: PublicKeyPause all minting and burning. Requires pauser role.
unpausemint: PublicKeyResume operations. Requires pauser role.
updateRolesmint: PublicKey, params: UpdateRoleParamsAssign a role to a new holder. Requires master authority.
updateMintermint: PublicKey, minterWallet: PublicKey, params: UpdateMinterParamsCreate or update a minter. Requires master authority.
transferAuthoritymint: PublicKey, newAuthority: PublicKeyTransfer master authority. Requires current master authority.
blacklistAddmint: PublicKey, address: PublicKey, targetTokenAccount: PublicKey, params: BlacklistAddParamsBlacklist an address and freeze their token account. SSS-2 only.
blacklistRemovemint: PublicKey, address: PublicKey, targetTokenAccount: PublicKeyRemove an address from the blacklist and thaw their account. SSS-2 only.
seizemint: PublicKey, blacklistedAddress: PublicKey, fromTokenAccount: PublicKey, toTokenAccount: PublicKey, amount: BNSeize tokens from a blacklisted address. SSS-2 only.
attestReservemint: PublicKey, params: AttestReserveParamsRecord an on-chain reserve attestation. Requires master authority.
initializeExtraAccountMetaListmint: PublicKeyInitialize the ExtraAccountMetaList for the transfer hook. Called once per mint.

Utilities

MethodParametersReturnsDescription
getAssociatedTokenAddressmint: PublicKey, owner: PublicKeyPublicKeyDerive the Token-2022 ATA for a mint/owner pair
createAssociatedTokenAccountInstructionpayer: PublicKey, mint: PublicKey, owner: PublicKeyTransactionInstructionBuild an ATA creation instruction for Token-2022

Event Parsing

The SDK provides utilities to parse Anchor events from transaction logs.

import { createEventParser, parseTransactionEvents } from "solana-stablecoin-standard";

// Parse events from a transaction
const tx = await connection.getTransaction(signature, {
  commitment: "confirmed",
});
const events = parseTransactionEvents(client.tokenProgram, tx.meta.logMessages);

for (const event of events) {
  switch (event.name) {
    case "tokensMinted":
      console.log(`Minted ${event.data.amount} tokens`);
      break;
    case "blacklistAdded":
      console.log(`Blacklisted ${event.data.blockedAddress}`);
      break;
  }
}

Supported event types: StablecoinInitialized, TokensMinted, TokensBurned, AccountFrozen, AccountThawed, ProgramPaused, ProgramUnpaused, RoleUpdated, MinterUpdated, AuthorityTransferred, BlacklistAdded, BlacklistRemoved, TokensSeized, AuditLogRecorded.

Oracle Module

The OracleModule provides Pyth price feed integration and reserve data construction.

import { OracleModule } from "solana-stablecoin-standard";

const oracle = new OracleModule(connection);

// Fetch a Pyth price
const price = await oracle.fetchPythPrice(pythUsdcFeedAccount);
console.log(OracleModule.formatPrice(price.price, price.exponent));

// Build reserve attestation data
const reserveData = await oracle.buildReserveData({
  reserveComponents: [
    { name: "US Treasury Bills", amountUsd: 800_000 },
    { name: "Bank Deposits", amountUsd: 200_000 },
  ],
  outstandingSupply: new BN(1_000_000_000_000), // 1M tokens (6 decimals)
  attestationUri: "https://example.com/audit/2026-02.pdf",
});

// Use in attestation instruction
await client.attestReserve(mint, {
  reserveHash: reserveData.reserveHash,
  totalReservesUsd: reserveData.totalReservesUsd,
  totalOutstanding: reserveData.totalOutstanding,
  attestationUri: reserveData.attestationUri,
});

OracleModule Methods

MethodDescription
fetchPythPrice(priceFeedAccount)Fetch the current price from a Pyth V2 price feed account
buildReserveData(params)Build a ReserveData object from reserve components, computing the hash and collateralization ratio
computeReserveHash(data)Compute a SHA-256 hash from arbitrary data (string or Buffer)
OracleModule.formatPrice(price, exponent)Format a Pyth price as a USD string (static method)

Presets Helper

import { PRESET_CONFIGS, getPresetAnchorEnum, StablecoinPreset } from "solana-stablecoin-standard";

// Get the full preset configuration
const sss2Config = PRESET_CONFIGS[StablecoinPreset.SSS2];
// {
//   preset: { sss2: {} },
//   enablePermanentDelegate: true,
//   enableTransferHook: true,
//   defaultAccountFrozen: false,
//   enableConfidentialTransfers: false,
// }

// Get just the Anchor enum variant for instruction params
const presetEnum = getPresetAnchorEnum(StablecoinPreset.SSS2);
// { sss2: {} }

Error Handling

All client methods wrap Anchor errors into SSSError instances with typed error codes.

import { SSSError } from "solana-stablecoin-standard";

try {
  await client.mintTokens(mint, amount, recipientATA);
} catch (err) {
  if (err instanceof SSSError) {
    console.log(err.code);      // 6005
    console.log(err.errorName);  // "MintQuotaExceeded"
    console.log(err.message);    // "MintQuotaExceeded (6005): Mint amount exceeds minter quota"
  }
}

Constants

import {
  SSS_TOKEN_PROGRAM_ID,          // 5ZBiFxX4ggWfNR5VhAQDRZauG6CvG84puS4SQiH8BcL4
  SSS_TRANSFER_HOOK_PROGRAM_ID,  // FmujD82V5FB6Nus7mbEV2a7cp5HG32gsiHykmtNSRJxy
  TOKEN_2022_PROGRAM_ID,         // TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
  ASSOCIATED_TOKEN_PROGRAM_ID,   // ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL
  SEEDS,                         // PDA seed buffers
} from "solana-stablecoin-standard";

License

MIT

Keywords

solana

FAQs

Package last updated on 13 Mar 2026

Related posts