
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
besfi-solana-js
Advanced tools
A JavaScript/TypeScript library for interacting with the Besfi Solana smart contract.
A JavaScript/TypeScript library for interacting with the Besfi Solana smart contract.
This library provides a set of utilities and functions to interact with the Besfi smart contract on the Solana blockchain. It handles operations such as:
npm install besfi-solana-js
When the user want to deposit SOL/Spl token to the Besfi program.
import { createDepositAndVaultAtaIfNeededAndNonceAccountInstructions, DepositInstructionParam } from 'besfi-solana-js';
// Deposit params receive from the backend/solver
const depositParams: DepositInstructionParam = {}
// Build necessary instructions for depositing
const instructions = await createDepositAndVaultAtaIfNeededAndNonceAccountInstructions(depositParams);
// Build the transaction with built instructions
const transaction = new Transaction().add(...instructions);
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
transaction.feePayer = user.publicKey;
// Send the transaction to the network
// Note: Transactions need to be signed by the user and user ephemeral account
const signature = await sendAndConfirmTransaction(connection, transaction, [user, userEphemeral], { commitment: 'confirmed' });
console.log(`Signature: ${signature}`);
When the pmm already paid the user, then the mpcs can settle the trade. Settlement needs two step
userEphemeral key, allow the mpcs can settle the trade with agreed informations from userimport { createUserPresignSettlementTransactionAndSerializeToString } from "besfi-solana-js";
// Build the presign transaction, serialize it to string, then send to the solver
const settlementPresign = await createUserPresignSettlementTransactionAndSerializeToString({
connection: connection,
tradeId: tradeId,
mpcPubkey: mpc.publicKey,
pmmPubkey: pmm.publicKey,
userEphemeral: userEphemeral,
});
console.log(`Settlement presign: ${settlementPresign}`);
// recover transaction from the presign string
const recoveredTransaction = Transaction.from(Buffer.from(settlementPresign, 'hex'));
// Sign the transaction with mpc keys
recoveredTransaction.partialSign(mpc);
// Send the transaction to the network
const latestBlockhash = await connection.getLatestBlockhash();
const sig = await connection.sendRawTransaction(recoveredTransaction.serialize(), {
skipPreflight: false,
})
await connection.confirmTransaction({
signature: sig,
blockhash: latestBlockhash.blockhash,
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight
}, 'confirmed')
console.log(`Settlement success at ${sig}`);
When the trade is timed out, the user can claim the deposit back.
import { createClaimInstructions } from "besfi-solana-js";
// Create claim instructions
const instructions = await createClaimAndRefundAtaAndProtocolAtaIfNeededInstructions({
tradeId,
connection,
userPubkey: user.publicKey,
})
// Build the transaction with built instructions
const transaction = new Transaction().add(...instructions);
// Send the transaction to the network
const signature = await sendAndConfirmTransaction(connection, transaction, [user], { commitment: 'confirmed' });
console.log(`Claim success at ${signature}`);
When the user deposit the SOL/Spl token, the mpcs can set the total fee for the trade.
import { createSetTotalFeeInstructions } from "besfi-solana-js";
const instructions = await createSetTotalFeeInstructions({
tradeId,
amount: '0.0001',
connection,
mpcPubkey: mpc.publicKey,
});
// Build the transaction with built instructions
const transaction = new Transaction().add(...instructions);
// Send the transaction to the network
const signature = await sendAndConfirmTransaction(connection, transaction, [mpc], { commitment: 'confirmed' });
console.log(`Set fee success at ${signature}`);
When some parties want to decode list of accounts, maybe fetched from a transaction.
import { decodeTradeDetailAccounts } from "besfi-solana-js";
// Some tx hash, maybe a deposit transaction
const txHash = `...`
const parsedTx = await connection.getParsedTransaction(txHash, 'confirmed');
const accounts = parsedTx?.transaction.message.accountKeys;
const accountPubkey = accounts.map((account) => account.pubkey);
const results = await decodePaymentReceiptAccounts(connection, accountPubkey);
console.log('Trade details', results.filter((result) => result.error !== null));
FAQs
A JavaScript/TypeScript library for interacting with the Besfi Solana smart contract.
The npm package besfi-solana-js receives a total of 1 weekly downloads. As such, besfi-solana-js popularity was classified as not popular.
We found that besfi-solana-js demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.