New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@fractalshq/token2022-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fractalshq/token2022-wrapper

Utilities and instruction builders for wrapping Token-2022 mints into SPL Token mints via the Token2022 Wrapper program.

latest
npmnpm
Version
0.1.5
Version published
Maintainers
2
Created
Source

@fractalshq/token2022-wrapper

Utilities and instruction builders for wrapping Token-2022 mints into SPL Token mints via the Token2022 Wrapper program.

Install

npm install @fractalshq/token2022-wrapper bn.js @solana/web3.js @solana/spl-token

Build locally (isolate from repo):

cd packages/token2022-wrapper
rm -rf node_modules
npm i
npm run build

Usage

Default Program (XNET Wrapper)

import { Connection, PublicKey, Transaction } from '@solana/web3.js';
import { buildWrap2022ToSplIx, getWrapperTokenMint } from '@fractalshq/token2022-wrapper';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const token2022Mint = new PublicKey('...');
const owner = new PublicKey('...');

const { preIxs, ixs, wrapperMint } = await buildWrap2022ToSplIx({
  connection,
  token2022Mint,
  owner,
  amount: 1_000_000, // base units per token2022 decimals
  createAtaIfMissing: true,
});

const tx = new Transaction();
(preIxs ?? []).forEach(ix => tx.add(ix));
ixs.forEach(ix => tx.add(ix));

console.log('Wrapper SPL mint:', wrapperMint.toBase58());

Custom Wrapping Contract

import { Connection, PublicKey, Transaction } from '@solana/web3.js';
import { buildWrap2022ToSplIx, getWrapperTokenMint } from '@fractalshq/token2022-wrapper';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const token2022Mint = new PublicKey('...');
const owner = new PublicKey('...');

// Use a custom Token2022 wrapper program
const customProgramId = new PublicKey('YourCustomWrapperProgramIdHere');

const { preIxs, ixs, wrapperMint } = await buildWrap2022ToSplIx({
  connection,
  token2022Mint,
  owner,
  amount: 1_000_000, // base units per token2022 decimals
  createAtaIfMissing: true,
  programId: customProgramId, // Specify custom program ID
});

const tx = new Transaction();
(preIxs ?? []).forEach(ix => tx.add(ix));
ixs.forEach(ix => tx.add(ix));

console.log('Custom wrapper SPL mint:', wrapperMint.toBase58());

Important Notes

Wrapper Contract Deployment

When using custom wrapping contracts (by specifying a programId), you are responsible for deploying and managing your own Token2022 Wrapper program. This library only provides the instruction builders and utilities to interact with any deployed Token2022 Wrapper program.

  • The default XNET Wrapper program (22WrapbNKwPSy3HcGQTTJpgv43tszbZdTEfBEWmGYX2V) is maintained and available for use
  • For custom deployments, ensure your wrapper program implements the same instruction interface and PDA derivation logic
  • All PDAs (wrapper mint, reserve authority, token accounts) are derived deterministically based on the program ID

Exports

  • buildWrap2022ToSplIx(params) - Main wrapper function (accepts optional programId)
  • createInitializeWrapperTokenInstruction(...) - Initialize wrapper (accepts optional programId)
  • createDepositAndMintWrapperTokensInstruction(...) - Deposit and mint wrapper tokens (accepts optional programId)
  • createWithdrawAndBurnWrapperTokensInstruction(...) - Withdraw and burn wrapper tokens (accepts optional programId)
  • PDA helpers (getWrapperTokenMint, getReserveAuthority, getReserveAuthorityTokenAccount) - accept optional programId
  • Constants and utilities

License

MIT

FAQs

Package last updated on 15 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts