Build On Flash

Integrating with Flash.trade made easy

Introduction

Flash.trade SDK written in typescript provides the easist way for developers, partners and others to integrate with flash.trade. This page will walk you through setting up the flash client, creating transactions and executing them.

Install the Flash SDK

npm install flash-sdk

yarn add flash-sdk

Setting up the Flash SDK

import { AnchorProvider, BN } from "@coral-xyz/anchor";
import { PerpetualsClient, PoolConfig } from 'flash-sdk';

const RPC_URL = process.env.RPC_URL;

// Configure the AnchorProvider
const provider: AnchorProvider = AnchorProvider.local(RPC_URL, {
    commitment: 'processed',
    preflightCommitment: 'processed',
    skipPreflight: true,
});

// Configure the pool you want to interact with 
// for devnet : devnet.1,devnet.2,devnet.3,devnet.4,devnet.5
// for mainnet : Crypto.1,Virtual.1,Governance.1,Community.1,Community.2
// all the pool details can be found by running `code ./node_modules/flash-sdk/dist/PoolConfig.json`
const POOL_CONFIG = PoolConfig.fromIdsByName('Crypto.1', 'mainnet-beta'); 

// You can now setup the Flash client
const flashClient = new PerpetualsClient(
    provider,
    POOL_CONFIG.programId,
    POOL_CONFIG.perpComposibilityProgramId,
    POOL_CONFIG.fbNftRewardProgramId,
    POOL_CONFIG.rewardDistributionProgram.programId,
    {
        prioritizationFee: 0, // this can be set dynamically by calling flashClient.setPrioritizationFee
    }
)

Last updated