Skip to content

Latest commit

 

History

History
62 lines (41 loc) · 1.42 KB

File metadata and controls

62 lines (41 loc) · 1.42 KB

Swap API (V1) - Quote, Build & Send (with Referral Accounts) Script

This script demonstrates how to get a quote for a swap, build the swap (with referral accounts), and then send the swap using the Jupiter V1 API. This is useful for when you want to earn fees from the swaps.

How to set up referral accounts

  1. Head to Jupiter Referral Dashboard, select the tokens that you want to earn fees from, and create a referral account. From the referral account, you will need to obtain your Referral Key.
  2. Create a new referral account programatically via the Jupiter Referral SDK

Prerequisites

  • Node.js (v16 or higher)
  • npm (v10 or higher)
  • Solana Wallet Private Key
  • Helius RPC API key
  • Jupiter V1 API Key (optional) - get it here

Usage

  1. Clone the repository
git clone https://github.com/Jupiter-DevRel/typescript-examples.git
  1. Navigate to the swap/quote-build-send-with-referral-accounts directory
cd swap/quote-build-send-with-referral-accounts
  1. Install the dependencies
npm install
  1. Run the script
npm run example

Create a referral token account

  1. Navigate to the swap/quote-build-send-with-referral-accounts directory
cd swap/quote-build-send-with-referral-accounts
  1. Install the dependencies
npm install
  1. Run the script
npm run create-token-account