Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/al366io/solana-transactions-wrapper
Handy tool to execute buy/sell transactions on the SOLANA chain
https://github.com/al366io/solana-transactions-wrapper
blockchain jupiter library solana swap wrapper
Last synced: about 3 hours ago
JSON representation
Handy tool to execute buy/sell transactions on the SOLANA chain
- Host: GitHub
- URL: https://github.com/al366io/solana-transactions-wrapper
- Owner: Al366io
- License: mit
- Created: 2024-01-22T17:14:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-27T07:26:27.000Z (8 months ago)
- Last Synced: 2025-02-03T14:45:27.104Z (9 days ago)
- Topics: blockchain, jupiter, library, solana, swap, wrapper
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/solana-transactions-wrapper
- Size: 59.6 KB
- Stars: 59
- Watchers: 4
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
solana-transactions-wrapper
Handy tool to execute buy/sell transactions on the SOLANA chain.
Installation
Install the package with npm:
npm install solana-transactions-wrapper
Usage
Importing the package
import { buy_token, sell_token, get_tokens_balances, get_token_balance } from 'solana-transactions-wrapper';
Buying a token
Parameters:
config: The buy function accepts a config object, as per buyConfig object type.
The buyConfig object type is defined as follows:
type buyConfig = {
RPC_ENDPOINT: string;
WALLET_PRIVATE_KEY: string;
ADDRESS_OF_TOKEN_TO_BUY: string;
AMOUNT_OF_SOLANA_TO_SPEND: number;
SLIPPAGE: number;
}
Usage:
await buy_token(config: buyConfig)
Logs Example:
Connection established 🚀
Wallet fetched ✅
Trying to buy token using "amount" SOL...
Transaction sent with txid: "transaction_id"
Waiting for confirmation... 🕒
Transaction confirmed ✅
Selling a token
Parameters:
config: The sell function accepts a config object, as per sellConfig object type.
The sellConfig object type is defined as follows:
type sellConfig = {
SELL_ALL: boolean;
RPC_ENDPOINT: string;
WALLET_PRIVATE_KEY: string;
ADDRESS_OF_TOKEN_TO_SELL: string;
AMOUNT_OF_TOKEN_TO_SELL?: number;
SLIPPAGE: number;
}
Usage:
await sell_token(config: sellConfig)
Logs Example:
Connection established 🚀
Wallet fetched ✅
Selling "amount" of "token_address"...
Transaction sent with txid: "transaction_id"
Waiting for confirmation... 🕒
Transaction confirmed ✅
Getting Account Tokens Balances
const tokens_balances = await get_tokens_balances(
RPC_ENDPOINT,
WALLET_PRIVATE_KEY
);
-
RPC_ENDPOINT: Your RPC endpoint to connect to. -
WALLET_PRIVATE_KEY: The private key of the wallet you want to get the tokens from.
This function returns a promise that resolves to an object mapping token addresses to their balance and symbol.
Getting Token Balance
const token_balance = await get_token_balance(
RPC_ENDPOINT,
WALLET_PRIVATE_KEY,
TOKEN_ADDRESS
);
-
RPC_ENDPOINT: Your RPC endpoint to connect to. -
WALLET_PRIVATE_KEY: The private key of the wallet you want to get the tokens from. -
TOKEN_ADDRESS: The address of the token you want to get the balance from.
This function returns a promise that resolves to the balance of the token.