SolanaStreamClient
SolanaStreamClient
Defined in: StreamClient.ts:147
Constructors
Constructor
new SolanaStreamClient(
clusterUrl,
cluster?,
commitment?,
programId?,
sendRate?,
sendThrottler?): SolanaStreamClient;Defined in: StreamClient.ts:167
Create Stream instance with flat arguments
Parameters
| Parameter | Type |
|---|---|
clusterUrl | string |
cluster? | ICluster |
commitment? | Commitment | ConnectionConfig |
programId? | string |
sendRate? | number |
sendThrottler? | PQueue |
Returns
SolanaStreamClient
Constructor
new SolanaStreamClient(options): SolanaStreamClient;Defined in: StreamClient.ts:179
Create Stream instance with options
Parameters
| Parameter | Type |
|---|---|
options | ClientCreationOptions |
Returns
SolanaStreamClient
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
alignedProxyProgram | readonly | Program<StreamflowAlignedUnlocks> | packages/stream/solana/StreamClient.ts:158 |
Methods
buildCreateMultipleTransactionInstructions()
buildCreateMultipleTransactionInstructions(
data,
extParams,
applyCustomAfterInstructions?): Promise<{
instructionsBatch: object[];
metadatas: string[];
metadataToRecipient: MetadataRecipientHashMap;
prepareInstructions: TransactionInstruction[];
}>;Defined in: StreamClient.ts:839
Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
data | ICreateMultipleStreamData | undefined | Stream base parameters and array of recipients with individual amounts and settings |
extParams | IPrepareCreateStreamExt | undefined | Transaction configuration including sender public key, native token handling, and custom instructions |
applyCustomAfterInstructions | boolean | true | - |
Returns
Promise<{
instructionsBatch: object[];
metadatas: string[];
metadataToRecipient: MetadataRecipientHashMap;
prepareInstructions: TransactionInstruction[];
}>
Create multiple transaction instructions
buildCreateMultipleTransactions()
buildCreateMultipleTransactions(
data,
extParams,
applyCustomAfterInstructions?): Promise<{
context: any;
hash: Readonly<{
blockhash: string;
lastValidBlockHeight: number;
}>;
metadatas: string[];
metadataToRecipient: MetadataRecipientHashMap;
prepareTx?: VersionedTransaction;
transactions: BatchItem[];
}>;Defined in: StreamClient.ts:942
Builds multiple transactions for creating stream/vesting contracts without signing or executing them. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
data | ICreateMultipleStreamData | undefined | Stream base parameters and array of recipients with individual amounts and settings |
extParams | IPrepareCreateStreamExt | undefined | Transaction configuration including sender public key, native token handling, and custom instructions |
applyCustomAfterInstructions | boolean | true | - |
Returns
Promise<{
context: any;
hash: Readonly<{
blockhash: string;
lastValidBlockHeight: number;
}>;
metadatas: string[];
metadataToRecipient: MetadataRecipientHashMap;
prepareTx?: VersionedTransaction;
transactions: BatchItem[];
}>
Multiple transaction information
Example
const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
// CRITICAL: Execute prepareTx first if it exists
if (result.prepareTx) {
await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
}
// Only then execute stream creation transactions
for (const item of result.transactions) {
await connection.sendAndConfirmTransaction(item.tx, [signer]);
}buildCreateTransaction()
buildCreateTransaction(data, extParams): Promise<{
context: any;
hash: string;
metadata?: Keypair;
metadataId: string;
tx: VersionedTransaction;
}>;Defined in: StreamClient.ts:349
Builds a transaction for creating a new stream/vesting contract without signing or executing it. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ICreateStreamData | Stream parameters including recipient, token, amount, schedule, and permissions |
extParams | IPrepareCreateStreamExt | Transaction configuration including sender public key, native token handling, and custom instructions |
Returns
Promise<{
context: any;
hash: string;
metadata?: Keypair;
metadataId: string;
tx: VersionedTransaction;
}>
Transaction and metadata information
buildCreateTransactionInstructions()
buildCreateTransactionInstructions(data, extParams): Promise<{
ixs: TransactionInstruction[];
metadata?: Keypair;
metadataId: string;
}>;Defined in: StreamClient.ts:284
Builds transaction instructions for creating a new stream/vesting contract without creating a transaction. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ICreateStreamData | Stream parameters including recipient, token, amount, schedule, and permissions |
extParams | IPrepareCreateStreamExt | Transaction configuration including sender public key, native token handling, and custom instructions |
Returns
Promise<{
ixs: TransactionInstruction[];
metadata?: Keypair;
metadataId: string;
}>
Transaction instructions and metadata ID
cancel()
cancel(cancelData, extParams): Promise<ITransactionResult>;Defined in: StreamClient.ts:1248
Attempts canceling the specified stream.
Parameters
| Parameter | Type | Description |
|---|---|---|
cancelData | IInteractData | Cancellation parameters including stream ID |
extParams | IInteractStreamExt | Transaction configuration including invoker wallet, token account validation, and compute settings |
Returns
Promise<ITransactionResult>
Transaction result
create()
create(data, extParams): Promise<ICreateResult>;Defined in: StreamClient.ts:383
Creates a new stream/vesting contract. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ICreateStreamData | Stream parameters including recipient, token, amount, schedule, and permissions |
extParams | ICreateStreamExt | Transaction configuration including sender wallet, native token handling, and compute settings |
Returns
Promise<ICreateResult>
Create result
createMultiple()
createMultiple(data, extParams): Promise<IMultiTransactionResult>;Defined in: StreamClient.ts:988
Creates multiple stream/vesting contracts. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
Parameters
| Parameter | Type | Description |
|---|---|---|
data | | ICreateMultipleStreamData | ICreateMultipleStreamData[] | Stream base parameters and array of recipients with individual amounts and settings |
extParams | ICreateStreamExt | Transaction configuration including sender wallet, metadata keys, and compute settings |
Returns
Promise<IMultiTransactionResult>
Multiple transaction information
createMultipleSequential()
createMultipleSequential(data, extParams): Promise<IMultiTransactionResult>;Defined in: StreamClient.ts:1074
Creates multiple stream/vesting contracts, and send all transactions sequentially. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee). In most cases, createMultiple should be used instead.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | | ICreateMultipleStreamData | ICreateMultipleStreamData[] | Stream base parameters and array of recipients with individual amounts and settings |
extParams | ICreateStreamExt | Transaction configuration including sender wallet, metadata keys, and compute settings |
Returns
Promise<IMultiTransactionResult>
Multiple transaction information
createUnchecked()
createUnchecked(data, extParams): Promise<ICreateResult>;Defined in: StreamClient.ts:684
Creates a new stream/vesting contract using unchecked instruction.
Unchecked instruction differs from the regular in:
- does not check for initialized associated token account (wallets with no control over their ATA should not be used as sender/recipient/partner or there are risks of funds being locked in the contract)
- initialized contract PDA off chain
If you are not sure if you should use create or create_unchecked, go for create to be safer.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ICreateStreamData | Stream parameters including recipient, token, amount, schedule, and permissions |
extParams | ICreateStreamExt | Transaction configuration including sender wallet, metadata keys, and compute settings |
Returns
Promise<ICreateResult>
Create result
extractErrorCode()
extractErrorCode(err): string;Defined in: StreamClient.ts:1947
Extracts error code from an error
Parameters
| Parameter | Type | Description |
|---|---|---|
err | Error | Error |
Returns
string
Error code
get()
get(getData): Promise<[string, Stream][]>;Defined in: StreamClient.ts:1663
Fetch streams/contracts by providing direction. Streams are sorted by start time in ascending order.
Parameters
| Parameter | Type | Description |
|---|---|---|
getData | IGetAllData | Query parameters including address, stream type filter, and direction filter |
Returns
Promise<[string, Stream][]>
Record of stream data
getAlignedProxyProgramId()
getAlignedProxyProgramId(): string;Defined in: StreamClient.ts:269
Returns
string
getClosedStreams()
getClosedStreams(owner, direction?): Promise<Record<string, Stream>>;Defined in: StreamClient.ts:1988
Gets closed streams for a given owner and direction
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
owner | string | undefined | Owner address |
direction | StreamDirection | StreamDirection.All | Stream direction |
Returns
Promise<Record<string, Stream>>
Record of closed streams
getCommitment()
getCommitment(): Commitment;Defined in: StreamClient.ts:261
Returns
Commitment
getConnection()
getConnection(): Connection;Defined in: StreamClient.ts:257
Returns
Connection
getDefaultFees()
getDefaultFees(): Promise<IFees>;Defined in: StreamClient.ts:1917
Get all defaults fees applied by the protocol.
Protocol will use fees set for WITHDRAWOR as default if they are set.
Returns
Promise<IFees>
getDefaultStreamflowFee()
getDefaultStreamflowFee(): Promise<number>;Defined in: StreamClient.ts:1908
Gets default streamflow fee
Returns
Promise<number>
Default streamflow fee
getFees()
getFees(getData): Promise<IFees>;Defined in: StreamClient.ts:1882
Gets fees for a given address
Parameters
| Parameter | Type | Description |
|---|---|---|
getData | IGetFeesData | Query parameters containing the partner address to check for custom fees |
Returns
Promise<IFees>
Fees
getOne()
getOne(getData): Promise<Stream>;Defined in: StreamClient.ts:1556
Fetch stream data by its id (address).
Parameters
| Parameter | Type | Description |
|---|---|---|
getData | IInteractData | Query parameters containing the stream ID to fetch |
Returns
Promise<Stream>
Stream data
getProgramId()
getProgramId(): string;Defined in: StreamClient.ts:265
Returns
string
getTotalFee()
getTotalFee(getFeesData): Promise<number>;Defined in: StreamClient.ts:1934
Returns total fee percent, streamflow fees + partner fees
Parameters
| Parameter | Type | Description |
|---|---|---|
getFeesData | IGetFeesData | structure with address for which we need to derive fee, either sender or partner usually |
Returns
Promise<number>
fee as floating number, so if fee is 0.99%, it will return 0.99
isAlignedUnlock()
isAlignedUnlock(streamPublicKey, senderPublicKey): boolean;Defined in: StreamClient.ts:1956
Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA. For migrated streams, the PDA was derived from the old metadata key.
Parameters
| Parameter | Type |
|---|---|
streamPublicKey | PublicKey |
senderPublicKey | PublicKey |
Returns
boolean
prepareCancelAlignedUnlockInstructions()
prepareCancelAlignedUnlockInstructions(cancelData, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1297
Creates Transaction Instructions for cancel
Parameters
| Parameter | Type | Description |
|---|---|---|
cancelData | IInteractData | Cancellation parameters including stream ID |
extParams | IPrepareStreamExt | Transaction configuration including invoker wallet, token account validation, and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
prepareCancelInstructions()
prepareCancelInstructions(cancelData, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1272
Creates Transaction Instructions for cancel
Parameters
| Parameter | Type | Description |
|---|---|---|
cancelData | IInteractData | Cancellation parameters including stream ID |
extParams | IPrepareStreamExt | Transaction configuration including invoker wallet address, token account validation, and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
prepareCancelLinearStream()
prepareCancelLinearStream(cancelData, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1349
Creates Transaction Instructions for cancel
Parameters
| Parameter | Type | Description |
|---|---|---|
cancelData | IInteractData | Cancellation parameters including stream ID |
extParams | IPrepareStreamExt | Transaction configuration including invoker wallet, token account validation, and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
prepareCreateAlignedUnlockInstructions()
prepareCreateAlignedUnlockInstructions(streamParams, extParams): Promise<ICreateStreamInstructions>;Defined in: StreamClient.ts:423
Parameters
| Parameter | Type |
|---|---|
streamParams | ICreateAlignedStreamData |
extParams | IPrepareCreateStreamExt |
Returns
Promise<ICreateStreamInstructions>
prepareCreateInstructions()
prepareCreateInstructions(streamParams, extParams): Promise<ICreateStreamInstructions>;Defined in: StreamClient.ts:412
Parameters
| Parameter | Type |
|---|---|
streamParams | ICreateStreamData |
extParams | IPrepareCreateStreamExt |
Returns
Promise<ICreateStreamInstructions>
prepareCreateLinearStreamInstructions()
prepareCreateLinearStreamInstructions(data, extParams): Promise<ICreateStreamInstructions>;Defined in: StreamClient.ts:561
Creates a new stream/vesting contract. All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ICreateStreamData | Stream parameters including recipient, token, amount, schedule, and permissions |
extParams | IPrepareCreateStreamExt | Transaction configuration including sender wallet, metadata keys, and compute settings |
Returns
Promise<ICreateStreamInstructions>
Create stream instructions
prepareCreateUncheckedInstructions()
prepareCreateUncheckedInstructions(__namedParameters, __namedParameters): Promise<{
ixs: TransactionInstruction[];
metadata: Keypair;
metadataPubKey: PublicKey;
}>;Defined in: StreamClient.ts:711
Create Transaction instructions for createUnchecked
Parameters
| Parameter | Type |
|---|---|
__namedParameters | ICreateStreamData |
__namedParameters | IPrepareCreateStreamExt |
Returns
Promise<{
ixs: TransactionInstruction[];
metadata: Keypair;
metadataPubKey: PublicKey;
}>
prepareTopupInstructions()
prepareTopupInstructions(topupData, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1504
Create Transaction instructions for topup
Parameters
| Parameter | Type | Description |
|---|---|---|
topupData | ITopUpData | Top-up parameters including stream ID and amount to add |
extParams | ITopUpStreamExt | Transaction configuration including invoker wallet, native token handling, and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
prepareTransferInstructions()
prepareTransferInstructions(transferData, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1436
Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract). Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
Parameters
| Parameter | Type | Description |
|---|---|---|
transferData | ITransferData | Transfer parameters including stream ID and new recipient address |
extParams | IPrepareStreamExt | Transaction configuration including invoker wallet and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
prepareUpdateInstructions()
prepareUpdateInstructions(data, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1833
Create Transaction instructions for update
Parameters
| Parameter | Type | Description |
|---|---|---|
data | IUpdateData | Update parameters including stream ID and new settings |
extParams | IPrepareStreamExt | Transaction configuration including invoker wallet and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
prepareWithdrawInstructions()
prepareWithdrawInstructions(withdrawData, extParams): Promise<TransactionInstruction[]>;Defined in: StreamClient.ts:1193
Creates Transaction Instructions for withdrawal
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawData | IWithdrawData | Withdrawal parameters including stream ID and amount to withdraw |
extParams | IPrepareStreamExt | Transaction configuration including invoker wallet address, token account validation, and compute settings |
Returns
Promise<TransactionInstruction[]>
Transaction instructions
searchStreams()
searchStreams(data): Promise<IProgramAccount<Stream>[]>;Defined in: StreamClient.ts:1735
Searches for streams/contracts by providing filters.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ISearchStreams | Search by mint, sender, recipient or closed status |
Returns
Promise<IProgramAccount<Stream>[]>
Record of stream data
topup()
topup(topupData, extParams): Promise<ITransactionResult>;Defined in: StreamClient.ts:1480
Tops up stream account with specified amount.
Parameters
| Parameter | Type | Description |
|---|---|---|
topupData | ITopUpData | Top-up parameters including stream ID and amount to add |
extParams | ITopUpStreamExt | Transaction configuration including invoker wallet, native token handling, and compute settings |
Returns
Promise<ITransactionResult>
Transaction result
transfer()
transfer(transferData, extParams): Promise<ITransactionResult>;Defined in: StreamClient.ts:1408
Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract). Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
Parameters
| Parameter | Type | Description |
|---|---|---|
transferData | ITransferData | Transfer parameters including stream ID and new recipient address |
extParams | IInteractStreamExt | Transaction configuration including invoker wallet and compute settings |
Returns
Promise<ITransactionResult>
Transaction result
update()
update(data, extParams): Promise<ITransactionResult>;Defined in: StreamClient.ts:1803
Attempts updating the stream auto withdrawal params and amount per period
Parameters
| Parameter | Type | Description |
|---|---|---|
data | IUpdateData | Update parameters including stream ID and new settings |
extParams | IInteractStreamExt | Transaction configuration including invoker wallet and compute settings |
Returns
Promise<ITransactionResult>
Transaction result
withdraw()
withdraw(withdrawData, extParams): Promise<ITransactionResult>;Defined in: StreamClient.ts:1158
Attempts withdrawing from the specified stream.
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawData | IWithdrawData | Withdrawal parameters including stream ID and amount to withdraw |
extParams | IInteractStreamExt | Transaction configuration including invoker wallet, token account validation, and compute settings |
Returns
Promise<ITransactionResult>
Transaction result