-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example code for users who facing issue while using the sdk
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Connection, Keypair, PublicKey } from '@solana/web3.js'; | ||
import base58 from 'bs58'; | ||
import { createRequire } from 'module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const SDK = require('@oselezi/solana-volume-sdk'); | ||
console.log('SDK Exports:', SDK); | ||
|
||
const { AMM } = SDK; | ||
|
||
// Initialize Solana connection | ||
const connection = new Connection('https://api.mainnet-beta.solana.com'); | ||
|
||
// Your private key and mint address | ||
const privateKeyBase58 = 'YOUR_PRIVATE_KEY'; | ||
const payerSecretKey = base58.decode(privateKeyBase58); | ||
const payerWallet = Keypair.fromSecretKey(payerSecretKey); | ||
const mint = new PublicKey('YOUR_TOKEN_MINT'); | ||
|
||
// Create an instance of the AMM class | ||
const amm = new AMM(connection, payerWallet, { disableLogs: false }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "solana-volume-sdk-example", | ||
"version": "0.0.1", | ||
"description": "Solana Auto AMM and Volume example", | ||
"scripts": { | ||
"start": "npx tsx index.ts" | ||
}, | ||
"type": "module", | ||
"author": "oselezi", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/oselezi/solana-volume-sdk.git" | ||
}, | ||
"dependencies": { | ||
"@oselezi/solana-volume-sdk": "^1.5.5", | ||
"@solana/web3.js": "^1.73.0", | ||
"bs58": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"sideEffects": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"module": "ESNext", | ||
"moduleResolution": "NodeNext", | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"skipLibCheck": true, | ||
"allowSyntheticDefaultImports": true | ||
} | ||
} |