Quick Start
Get up and running with rFlow in under 5 minutes. This guide will walk you through connecting to the protocol and fetching available deals.
Before you begin
Make sure you have a Solana wallet with some devnet SOL for testing. You can get devnet SOL from the Solana Faucet.
Prerequisites#
- Node.js 18+ or Bun 1.0+
- A Solana wallet (Phantom, Solflare, etc.)
- Basic knowledge of TypeScript and Solana
Installation#
Install the required dependencies:
Terminal
$npm install @coral-xyz/anchor @solana/web3.js @solana/spl-token
Setup#
Connect to the rFlow program on devnet:
1
Import dependencies
typescript
import { AnchorProvider, Program, BN } from "@coral-xyz/anchor";import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";// rFlow Program ID (Devnet)const PROGRAM_ID = new PublicKey( "2yUwGR18L5a8UqfkX49M4SenYCrS4B48chioKWCnMG3y");2
Create connection and provider
typescript
// Connect to devnetconst connection = new Connection(clusterApiUrl("devnet"), "confirmed");// Create provider with your walletconst provider = new AnchorProvider( connection, wallet, // Your wallet adapter { commitment: "confirmed" });// Initialize program (you'll need the IDL from the repo)import idl from "./idl/payflow.json";const program = new Program(idl, provider);3
Fetch protocol config
typescript
// Derive Protocol Config PDAconst [configPDA] = PublicKey.findProgramAddressSync( [Buffer.from("protocol_config")], PROGRAM_ID);// Fetch configconst config = await program.account.protocolConfig.fetch(configPDA);console.log("Protocol Fee:", config.feeBps / 100, "%");console.log("Total Deals:", config.dealCounter.toString());console.log("Paused:", config.isPaused);Fetch Available Deals#
Get all yield deals currently available on the marketplace:
fetch-deals.ts
1// Fetch all deal accounts2const allDeals = await program.account.yieldDeal.all();34// Filter for available deals (status = Created)5const availableDeals = allDeals.filter(6 (deal) => deal.account.status.created !== undefined7);89console.log("Available deals:", availableDeals.length);1011for (const { publicKey, account } of availableDeals) {12 console.log("---");13 console.log("Deal PDA:", publicKey.toBase58());14 console.log("Seller:", account.seller.toBase58());15 console.log("Price:", account.sellingPrice.toNumber() / 1e6, "USDC");16 console.log("Duration:", account.durationDays, "days");17 console.log("Expected Yield:", account.expectedYield.toNumber() / 1e6, "USDC");18}You're connected!
You're now connected to the rFlow protocol. Check out the Integration Guide to learn how to create and buy deals.