Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@mirrorworld/library.wallet.new
Advanced tools
@mirrorworld/library.wallet
Client SDKThis SDK contains the client side methods for the Game Wallet Solana Program
🚨 Please make sure to add this NPM token in your
.npmrc
file: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
yarn add @mirrorworld/library.wallet
Import the GameWalletLib
instance into your client. It expects a connection
and wallet
instance. You can get these
by using one of the Solana Wallet Adapters your application will use to connect to a Solana RPC.
These transactions require you to sign the transaction using your wallet. That means you need to have SOL. You can request SOL from the SolFaucet
import {
GameWalletLib,
GAME_WALLET_PROGRAM_ID
} from '@mirrorworld/library.wallet';
const connection = useConnection()
/** Make sure your wallet is initialized and connected to the browser before providing to GameWalletLib */
const wallet = useWallet()
/** GameWalletLib instance */
const gameWalletLib = new GameWalletLib(
GAME_WALLET_PROGRAM_ID,
connection,
wallet
);
Example: You can see example project in this repo here:
The Token Config PDA account is the main part of the Game Wallet Program which is created from the token mint account.
const tokenDecimal = 9;
const isPaused = false;
const canDeposit = true;
const canWithdraw = true;
const canSpend = true;
const canDistribute = true;
const isWithdrawServiceFeeEnable = true;
const withdrawServiceFeePercentage = new BN(1);
const isSpendServiceFeeEnable = false;
const spendServiceFeePercentage = new BN(1);
const isDistributionServiceFeeEnable = false;
const distributionServiceFeePercentage = new BN(1);
const isMinWithdrawEnable = false;
const isMaxWithdrawEnable = false;
const minWithdraw = new BN((0.1 * LAMPORTS_PER_SOL));
const maxWithdraw = new BN((3.5 * LAMPORTS_PER_SOL));
let initializeTokenConfigTransaction = await gameWalletLib.createInitializeTokenConfigTransaction(tokenDecimal, isPaused, canDeposit, canWithdraw, canSpend, canDistribute,
isWithdrawServiceFeeEnable, withdrawServiceFeePercentage, isSpendServiceFeeEnable, spendServiceFeePercentage, isDistributionServiceFeeEnable, distributionServiceFeePercentage,
isMinWithdrawEnable, isMaxWithdrawEnable, minWithdraw, maxWithdraw,
signingAuthorityWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey, tokenMintAccount, incomeAccount);
gameWalletLib.signTransaction(initializeTokenConfigTransaction, signingAuthorityWalletSecretKey);
const initializeTokenConfigTransactionHash = await connection.sendRawTransaction(initializeTokenConfigTransaction.serialize());
console.log("initializeTokenConfigTransactionHash: ", initializeTokenConfigTransactionHash);
See example here
The deposit method in the program create the user token config and deposit the amount in the deposit pool
let depositTransaction = await gameWalletLib.createDepositTransaction(amount, userWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey);
gameWalletLib.signTransaction(depositTransaction, signingAuthorityWalletSecretKey);
gameWalletLib.signTransaction(depositTransaction, userWalletSecretKey);
const depositTransactionHash = await connection.sendRawTransaction(depositTransaction.serialize());
console.log("depositTransactionHash: ", depositTransactionHash);
See example here
The Withdrawal method in the program is the created by the user they want to withdraw amount from the deposit pool
let withdrawTransaction = await gameWalletLib.createWithdrawTransaction(amount, userWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey, incomeAccount, userWalletKeypair.publicKey);
gameWalletLib.signTransaction(withdrawTransaction, signingAuthorityWalletSecretKey);
gameWalletLib.signTransaction(withdrawTransaction, userWalletSecretKey);
const withdrawTransactionHash = await connection.sendRawTransaction(withdrawTransaction.serialize());
console.log("withdrawTransactionHash: ", withdrawTransactionHash);
See example here
The Withdrawal without user method in the program is the created by the user they want to withdraw amount from the deposit pool
let withdrawWithoutUserTransaction = await gameWalletLib.createWithdrawWithoutUserTransaction(amount, signingAuthorityWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey, incomeAccount, userWalletKeypair.publicKey);
gameWalletLib.signTransaction(withdrawWithoutUserTransaction, signingAuthorityWalletSecretKey);
const withdrawWithoutUserTransactionHash = await connection.sendRawTransaction(withdrawWithoutUserTransaction.serialize());
console.log("withdrawWithoutUserTransactionHash: ", withdrawWithoutUserTransactionHash);
See example here
The spend method in the program is for when user spend amount from his deposit pool
let spendTransaction = await gameWalletLib.createSpendTransaction(amount, userWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey, incomeAccount);
gameWalletLib.signTransaction(spendTransaction, signingAuthorityWalletSecretKey);
gameWalletLib.signTransaction(spendTransaction, userWalletSecretKey);
const spendTransactionHash = await connection.sendRawTransaction(spendTransaction.serialize());
console.log("spendTransactionHash: ", spendTransactionHash);
See example here
The spend without user method in the program is for when user spend amount from his deposit pool and user don't need to sign the transaction
let spendWithoutUserTransaction = await gameWalletLib.createSpendWithoutUserTransaction(amount, signingAuthorityWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey, incomeAccount);
gameWalletLib.signTransaction(spendWithoutUserTransaction, signingAuthorityWalletSecretKey);
const spendWithoutUserTransactionHash = await connection.sendRawTransaction(spendWithoutUserTransaction.serialize());
console.log("spendWithoutUserTransactionHash: ", spendWithoutUserTransactionHash);
See example here
The add deposit supply method in the program is for add the supply in the deposit pool
let addDepositSupplyTransaction = await gameWalletLib.createAddDepositSupplyTransaction(amount, signingAuthorityWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, signingAuthorityWalletKeypair.publicKey);
gameWalletLib.signTransaction(addDepositSupplyTransaction, signingAuthorityWalletSecretKey);
const addDepositSupplyTransactionHash = await connection.sendRawTransaction(addDepositSupplyTransaction.serialize(), {skipPreflight: false});
console.log("addDepositSupplyTransactionHash: ", addDepositSupplyTransactionHash);
See example here
The add distribution supply method in the program is for add the supply in the distribution pool
let addDistributeSupplyTransaction = await gameWalletLib.createAddDistributeSupplyTransaction(amount, signingAuthorityWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, signingAuthorityWalletKeypair.publicKey);
gameWalletLib.signTransaction(addDistributeSupplyTransaction, signingAuthorityWalletSecretKey);
const addDistributeSupplyTransactionHash = await connection.sendRawTransaction(addDistributeSupplyTransaction.serialize());
console.log("addDistributeSupplyTransactionHash: ", addDistributeSupplyTransactionHash);
See example here
The distribution method in the program is for when user eran new token then those token will be added to the user deposit pool from the distribution pool
let createDistributeTransaction = await gameWalletLib.createDistributeTransaction(amount, userWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey, incomeAccount);
gameWalletLib.signTransaction(createDistributeTransaction, signingAuthorityWalletSecretKey);
gameWalletLib.signTransaction(createDistributeTransaction, userWalletSecretKey);
const createDistributeTransactionHash = await connection.sendRawTransaction(createDistributeTransaction.serialize());
console.log("createDistributeTransactionHash: ", createDistributeTransactionHash);
See example here
The distribution without user method in the program is for when user eran new token then those token will be added to the user deposit pool from the distribution pool and user not need to sign the transaction
let distributeWithoutUserTransaction = await gameWalletLib.createDistributeWithoutUserTransaction(amount, signingAuthorityWalletKeypair.publicKey, signingAuthorityWalletKeypair.publicKey,
tokenMintAccount, userWalletKeypair.publicKey, incomeAccount);
gameWalletLib.signTransaction(distributeWithoutUserTransaction, signingAuthorityWalletSecretKey);
const distributeWithoutUserTransactionHash = await connection.sendRawTransaction(distributeWithoutUserTransaction.serialize());
console.log("distributeWithoutUserTransactionHash: ", distributeWithoutUserTransactionHash);
See example here
Name | Description |
---|---|
Token Config | Program config for the token pda account |
User Token Config | User config related to the token pda account |
Deposit Pool | Deposit Pool pda account |
Deposit Pool Token Account | Deposit Pool pda token account |
Distribution Pool | Distribution Pool pda account |
Distribution Pool Token Account | Distribution Pool pda token account |
FAQs
game wallet SDK
The npm package @mirrorworld/library.wallet.new receives a total of 2 weekly downloads. As such, @mirrorworld/library.wallet.new popularity was classified as not popular.
We found that @mirrorworld/library.wallet.new demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.