Skip to main content
Streamflow SDK
Updated over 3 months ago

app.streamflow.finance is a React application that uses Streamflow's JS SDK directly.

  • Use the JS SDK to interact with the protocol => NPM package

    • It's possible to integrate with our JS SDK across all chains which Streamflow currently supports

  • Use the Rust SDK to integrate within a Solana program => Rust Crate

Methods

A protocol is a Program that lives on-chain. To interact with the Streamflow protocol you'll need to make use of pre-defined Methods, which are called within the blockchain transaction.

Create

Authority: Anyone

Creates a Contract, usually accepts these parameters

	amount: u64,
period: u64,
amount_per_period: u64,
start: u64,
cliff_amount: u64,
cancelable_by_sender: bool,
cancelable_by_recipient: bool,
transferable_by_sender: bool,
transferable_by_recipient: bool,
can_topup: bool,
pausable: bool,
can_update_rate: bool,
automatic_withdrawal: bool,
withdrawal_frequency: u64,
contract_name: vector<u8>,
recipient: address,
partner: address,

All other parameters that are part of stream structure are calculated.

Validations:

assert!(amount_per_period <= amount, EBAD_INPUT_AMOUNT_PER_PERIOD);
assert!(amount_per_period > 0, EBAD_INPUT_AMOUNT_PER_PERIOD);

if (cliff_amount > 0) {
assert!(cliff_amount <= amount, EBAD_INPUT_CLIFF_AMOUNT);
};
assert!(period > 0, EBAD_INPUT_PERIOD);
assert!(withdrawal_frequency == 0 || withdrawal_frequency >= period, EBADINPUT);

assert!(now <= start, EBAD_INPUT_START);
assert!(start < now + SEVENTY_YEARS_IN_SECS, EBAD_INPUT_START);

Update

Authority: Sender

Updates a Contract, usually accepts these parameters

				automatic_withdrawal: Option<bool>,
withdrawal_frequency: Option<u64>,
amount_per_period: Option<u64>,

All parameters are optional.

  • withdrawal_frequency is used only if automatic_withdrawal parameter is set to true

  • update allows only to enable automatic_withdrawal (disabling may be tricky because we also need to notify Worker for that, but in theory we can allow disabling AW)

  • amount_per_period is accepted only if can_update_rate is enabled

Cancel

Authority: configured by cancelable_by_sender and cancelable_by_recipient flags

Cancel a Contract.

  • all unlocked funds by the time of cancellation are withdrawn (including fees)

  • all leftover funds are returned to the Sender (including fees)

Pause

Authority: Sender if pausable is enabled

Pause a Contract

  • when contract is paused, unlock calculation is halted

  • all already unlocked funds may be withdrawn

Unpause

Authority: Sender if pausable is enabled and contract is in pause state

Unpauses a Contract

  • continue unlock calculation

Withdraw

Authority: Recipient or Withdrawor if automatic_withdrawal is enabled

Withdraw some amount to Recipient address, usually accepts these parameters

Copy

amount: u64
  • accepts 18446744073709551615 as magical number to withdraw all unlocked funds

  • can’t withdraw more than unlocked

  • fees are transferred according to withdrawn amount

Transfer

Authority: configured by transferable_by_sender and transferable_by_recipient flags

Change Recipient address, usually accepts these parameters

Copy

new_recipient: address
  • on transfer unlocked funds remain in a contract (so new recipient can withdraw them)

See also:


Something we didn't cover?

We've tried to cover as much as possible in this guide, but there is always room for improvement. If we missed something, or you'd like to simply share your ideas, love, and support, email us at [email protected]

Someone will be in touch with you in no time. ✌️

Did this answer your question?