Composable APIs
Composable APIs
3-phase transaction model - get instructions, build, sign, and execute on Solana.
The composable API is a set of TypeScript functions that wrap SolanaStreamClient with intent-specific defaults and a clean 3-phase transaction model.
import {
createLock, createLockBatch,
createVesting, createVestingBatch,
withdraw, topup, transfer, cancel, update,
buildTransaction, sign, execute, executeBatch, executeBatchSequential,
} from "@streamflow/stream/solana/api";The 3-Phase Transaction Model
Phase 1 - Get instructions
Call a creation or lifecycle function. It returns an InstructionResult with the raw TransactionInstruction[]. Nothing is sent on-chain yet.
const result = await createLock(params, invoker, env);
// result: { instructions, signers?, metadataPubKey? }Phase 2 - Build transaction
Assemble a versioned transaction with a fresh blockhash and compute budget instructions.
const built = await buildTransaction(
result.instructions,
{ feePayer: invoker.publicKey, computeLimit: 200_000 },
env,
);
// built: { transaction, blockhashWithExpiryBlockHeight, context }Phase 3 - Sign and execute
Sign the transaction, then submit it to the network.
await sign(built.transaction, [invoker, ...(result.signers ?? [])]);
const signature = await execute(built, env);Why composable?
- Custom fee payer - pass any wallet as
feePayerinbuildTransaction - Custom compute budget - tune
computeLimitandcomputePrice - Multi-sig - collect signatures from multiple parties before executing
- Inspect first - examine instructions before committing to an on-chain action
- Batch execution - build multiple transactions, then send with
executeBatch()orexecuteBatchSequential()
Quick reference
The Type column shows each function's return type. All functions are async and return a Promise of the listed type.
Prop
Type