UNPKG

@cryptoscan/orca-sdk

Version:

The fastest and easiest way to trade on Orca.

19 lines (16 loc) 647 B
import { getWallet } from '@cryptoscan/solana-wallet-sdk'; import { OrcaApi } from '@cryptoscan/orca-sdk'; import 'dotenv/config' import { Connection } from '@solana/web3.js'; const connectionUrl = process.env.WS_CONNECTION_URL; const connection = connectionUrl ? new Connection(process.env.CONNECTION_URL!, {wsEndpoint: connectionUrl }) : undefined; const wallet = getWallet(process.env.SECRET_KEY!); const coinAddress = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'; const sol = 0.05; const api = new OrcaApi({ connection }); console.log(wallet.publicKey.toString()) api.buy({ wallet, coinAddress, sol, }).then((tx) => console.log(tx))