Al366io / solana-transactions-wrapper

Handy tool to execute buy/sell transactions on the SOLANA chain
https://www.npmjs.com/package/solana-transactions-wrapper
MIT License
51 stars 11 forks source link

How-to for newbies #12

Closed jcatal closed 5 months ago

jcatal commented 5 months ago

Hello, I'm totally confused and I can't figure out what to do to make the stuff work. I followed your instructions but not sure what to do : not clear for newbies, I have node.js and package installed. I'm not used with typescript, can you please kindly elaborate on explaining how to make it work, some kind of step by step tutorial. It would be very helpful, thanks a lot .

Al366io commented 5 months ago

Hello, you don't necessarily need to use typescript, it's just going to save you some headaches but you can easily use JS.

Once you install the package in your project (i.e. have a package.json file that states what version of solana-transactions-wrapper you have) then you can import the main functions that are available in the package.

import { buy_token, sell_token, get_tokens_balances, get_token_balance } from 'solana-transactions-wrapper';

Step after which you can then easily use those functions:

const RPC_ENDPOINT = // your rpc endpoint here
const WALLET_PRIVATE_KEY = // your wallet private key here
const tokens_balances = await get_tokens_balances(
  RPC_ENDPOINT,
  WALLET_PRIVATE_KEY
);
console.log("My account tokens balances: ", tokens_balances)