SDK Quick Start

Get up and running with the Yoink SDK in just a few minutes.

Prerequisites

Before installing the Yoink SDK, make sure you have:

  • Node.js (version 16 or higher)

  • npm or yarn package manager

  • Basic knowledge of JavaScript/TypeScript

  • Solana wallet for signing transactions

Installation

Using npm

npm install yoink-sdk

Using yarn

yarn add yoink-sdk

Using pnpm

pnpm add yoink-sdk

Required Dependencies

The SDK requires these Solana dependencies (automatically installed):

npm install @solana/web3.js @solana/spl-token @coral-xyz/anchor

Quick Setup

1. Import the SDK

import { YoinkSDK } from 'yoink-sdk';
import { Connection, Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
import { AnchorProvider } from "@coral-xyz/anchor";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";

2. Initialize Connection and Provider

// For testnet (Eclipse)
const connection = new Connection("https://staging-rpc.dev2.eclipsenetwork.xyz");

// For Solana mainnet
// const connection = new Connection("https://api.mainnet-beta.solana.com");

const wallet = new NodeWallet(yourKeypair);
const provider = new AnchorProvider(connection, wallet, { commitment: "confirmed" });

3. Create SDK Instance

const sdk = new YoinkSDK(provider);

Environment Variables

Create a .env file with your RPC endpoint:

# For testnet (current default)
SOLANA_RPC_URL=https://staging-rpc.dev2.eclipsenetwork.xyz

# For Solana mainnet
# SOLANA_RPC_URL=https://api.mainnet-beta.solana.com

Verification

Test your installation with a simple script:

import { YoinkSDK } from "yoink-sdk";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { AnchorProvider } from "@coral-xyz/anchor";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";

async function testInstallation() {
  const connection = new Connection(process.env.SOLANA_RPC_URL!);
  const wallet = new NodeWallet(Keypair.generate());
  const provider = new AnchorProvider(connection, wallet, { commitment: "confirmed" });
  
  const sdk = new YoinkSDK(provider);
  console.log("✅ SDK initialized successfully!");
  console.log("Program ID:", sdk.program.programId.toBase58());
  
  // Test global account fetch
  try {
    const global = await sdk.getGlobalAccount();
    console.log("✅ Connected to Yoink protocol");
    console.log("Fee basis points:", global.feeBasisPoints.toString());
  } catch (error) {
    console.error("❌ Connection failed:", error);
  }
}

testInstallation();

Next Steps

Troubleshooting

TypeError: Cannot read properties of undefined

Make sure you're using Node.js 16+ which has built-in support for BigInt.

Module not found errors

Install all required dependencies:

npm install @solana/web3.js @solana/spl-token @coral-xyz/anchor bn.js

TypeScript compilation errors

Update your tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ES2020",
    "lib": ["ES2020"],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}

Need help? Visit our GitHub repository or check the README.

Last updated