Withdraw from Streams
This section assumes that you have already gone through the setup part.
See the Access Control guide for an overview of who is allowed to withdraw from streams.
Withdrawing from streams means claiming the assets that have become due to the recipient, who has the option to direct the withdrawal to an alternative address of their choice.
There are four withdrawal functions:
withdraw
: withdraws a specific amount of assets.withdrawMax
: withdraws the maximum withdrawable amount of assets.withdrawMaxAndTransfer
: withdraws the maximum withdrawable amount and transfers the NFT.withdrawMultiple
: withdraws specific amounts of assets from multiple streams at once.
To call any of these functions, you need to have created a stream. If you don't have one yet, go back to the
previous guide and create a stream with a brief duration, assigning
the StreamManagement
contract as the recipient. Then, you can use the withdraw
function like this:
loading...
In this example, the withdrawal address and withdrawal amount are hard-coded for demonstration purposes. However, in a
production environment, these values would likely be adjustable parameters determined by the user. Alternatively, you
can use withdrawableAmountOf
function to determine how much amount of assets is available to withdraw.
In addition to the withdraw
function, there is the withdrawMax
function, which you can use to withdraw the maximum
withdrawable amount of assets at the time of invocation:
loading...
What withdrawMax
does is call the
withdrawableAmountOf
function
and pass its value to withdraw
.
Similar to withdrawMax
, you can use withdrawMaxAndTransfer
to withdraw the maximum withdrawable assets and at the
same time, transfer the NFT to another address.
Lastly, there is the withdrawMultiple
function, with which you can use to withdraw from multiple streams at once:
loading...