The Jupiter Developer Platform is live. Previous portal users keep their rate limits for free until 30 June 2026 — set up billing on the new platform before then. See the Migration Guide for details.
This example builds, signs, and sends a deposit transaction.
1
Import Dependencies
Import the packages you need for Solana RPC and Jupiter Lend (Earn) SDK operations.
import { Connection, Keypair, PublicKey, Transaction, sendAndConfirmTransaction,} from "@solana/web3.js";import BN from "bn.js";import { getDepositIxs } from "@jup-ag/lend/earn";import fs from "fs";import path from "path";
2
Set up connection and deposit parameters
Set your RPC, signer, asset mint, and deposit amount.
const RPC_URL = "https://api.mainnet-beta.solana.com";const userKeypair = Keypair.generate(); // <-- Replace this with your walletconst ASSET_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const DEPOSIT_AMOUNT = new BN(10_000_000);
If your signer is stored as a local JSON keypair file, you can load it using the helper function below.
import { Connection, Keypair, PublicKey, Transaction, sendAndConfirmTransaction,} from "@solana/web3.js";import BN from "bn.js";import { getDepositIxs } from "@jup-ag/lend/earn";import fs from "fs";import path from "path";const KEYPAIR_PATH = "/path/to/your/keypair.json"; // Path to your local keypair file (update this path)const ASSET_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // Asset mint to deposit (USDC for example)const DEPOSIT_AMOUNT = new BN(10_000_000); // Amount to deposit, in smallest units (e.g., 1 USDC = 1_000_000)const RPC_URL = "https://api.mainnet-beta.solana.com"; // RPC endpointfunction loadKeypair(keypairPath: string): Keypair { const fullPath = path.resolve(keypairPath); const secret = JSON.parse(fs.readFileSync(fullPath, "utf8")); return Keypair.fromSecretKey(new Uint8Array(secret));}// 1. Load user keypair and establish connectionconst userKeypair = loadKeypair(KEYPAIR_PATH);const connection = new Connection(RPC_URL, { commitment: "confirmed" });const signer = userKeypair.publicKey;// 2. Get deposit instructions from SDKconst { ixs: depositIxs } = await getDepositIxs({ connection, signer, asset: ASSET_MINT, amount: DEPOSIT_AMOUNT,});if (!depositIxs?.length) { throw new Error("No deposit instructions returned by Jupiter Lend SDK.");}// 3. Build the transaction with latest blockhash and add deposit instructions// This prepares the transaction ready to be signed and sentconst latestBlockhash = await connection.getLatestBlockhash();const transaction = new Transaction({ feePayer: signer, ...latestBlockhash,});transaction.add(...depositIxs);transaction.sign(userKeypair);// 4. Sign and send the transactionconst signature = await sendAndConfirmTransaction(connection, transaction, [userKeypair]);console.log("Deposit successful! Signature:", signature);