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
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
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 ifautomatic_withdrawal
parameter is set totrue
update
allows only to enableautomatic_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 ifcan_update_rate
is enabled
Cancel
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
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
Unpause
Authority: Sender if pausable
is enabled and contract is in pause
state
Unpauses a Contract
continue unlock calculation
Withdraw
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 fundscan’t withdraw more than unlocked
fees are transferred according to withdrawn amount
Transfer
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. ✌️