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
npminstallflash-sdkyarnaddflash-sdk
Setting up the Flash SDK
import { AnchorProvider, BN } from"@coral-xyz/anchor";import { PerpetualsClient, PoolConfig } from'flash-sdk';constRPC_URL=process.env.RPC_URL;// Configure the AnchorProviderconstprovider: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`constPOOL_CONFIG=PoolConfig.fromIdsByName('Crypto.1','mainnet-beta'); // You can now setup the Flash clientconstflashClient=newPerpetualsClient( 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 })