The FluxBeam Pool API allows developers to quickly and easily integrate the creation of pools within their platform.
import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js';
const form = {
payer: "", // Wallet address of the payer
tokenA: "", // Token A Mint
tokenB: "", // Token B Mint
tokenAAmount: "", // Token A Liquidity Amount
tokenBAmount: "" // Token B Liquidity Amount
}
const resp = await (
await fetch(`https://api.fluxbeam.xyz/v1/token_pools`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
"payer": form.payer,
"token_a": form.tokenA,
"token_b": .form.tokenB,
"token_a_amount": form.tokenAAmount,
"token_b_amount": form.tokenBAmount
})
})).json()
console.log("Pool Address:", resp.pool)
//Decode the transaction from base64
const swapTransactionBuf = Buffer.from(resp.transaction, 'base64');
const transaction = VersionedTransaction.deserialize(swapTransactionBuf);
console.log("Transaction",transaction);
//Sign the transaction with the payer wallet
transaction.sign([wallet.payer]);
//Execute the transaction
const client= new Connection('{RPC_URL}');
const sig = client.sendRawTransaction(transaction.serialize(), {maxRetries: 3, skipPreflight: true})
console.log("Transaction Signature:", sig)