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.
- 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. - Create a new referral account programatically via the Jupiter Referral SDK
- 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
- Clone the repository
git clone https://github.com/Jupiter-DevRel/typescript-examples.git- Navigate to the
swap/quote-build-send-with-referral-accountsdirectory
cd swap/quote-build-send-with-referral-accounts- Install the dependencies
npm install- Run the script
npm run example- Navigate to the
swap/quote-build-send-with-referral-accountsdirectory
cd swap/quote-build-send-with-referral-accounts- Install the dependencies
npm install- Run the script
npm run create-token-account