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.
npm install @solana/web3.js@1 # Using v1 of web3.js instead of v2npm install dotenv # If required for wallet setup
RPC
Set up RPC
NOTESolana provides a default RPC endpoint. However, as your application grows, we recommend you to always use your own or provision a 3rd party provider’s RPC endpoint such as Helius or Triton.
import { Connection } from "@solana/web3.js";const connection = new Connection('https://api.mainnet-beta.solana.com');
Wallet
Set up Development Wallet
NOTE
You can paste in your private key for testing purposes but this is not recommended for production applications.
If you want to store your private key in the project directly, you can do it via a .env file.
To set up a development wallet via .env file, you can use the following script.
// index.jsimport { Keypair } from '@solana/web3.js';import dotenv from 'dotenv';require('dotenv').config();const wallet = Keypair.fromSecretKey(bs58.decode(process.env.PRIVATE_KEY || ''));
# .envPRIVATE_KEY=""
To set up a development wallet via a wallet generated via Solana CLI, you can use the following script.
import { Keypair } from '@solana/web3.js';import fs from 'fs';const privateKeyArray = JSON.parse(fs.readFileSync('/Path/To/.config/solana/id.json', 'utf8').trim());const wallet = Keypair.fromSecretKey(new Uint8Array(privateKeyArray));
The Lend API provides 2 ways to interface with the Earn functions in the Jupiter Lend Program. You can either make a post request to directly get the Transaction, or Instruction which can be used for CPI or composing with additional instructions.
To use the Transaction method, simply request to the endpoints without -instructions suffix directly, as shown in the examples above. The API will respond with an unsigned base64 transaction for the signer to sign, then sent to the network for execution.
In some use cases, you’d prefer to utilize the instructions instead of the serialized transaction, so you can utilize with CPI or compose with other instructions. You can make a post request to -instructionsendpoints instead.
Building with Instuctions Code Snippet
Example code snippet of using /deposit-instructions endpoint and building a transaction with the instructions.
Jupiter Lend provides Earnings for individual tokens, meaning SOL and USDC will be deposited in isolation. To get all token information such as the underlying token, supply, rates and liquidity information.