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.
There are three functions that can be used to withdraw from streams:
withdraw
: withdraws a specific amount of assetswithdrawMax
: withdraws the maximum amount of assets available at the time of invocationwithdrawMultiple
: withdraws specific amounts of assets from multiple streams at once
To call any of the functions above, you must first have an active stream. If you don't have one yet, create a stream
with a brief duration, and assign the StreamManagement
contract as the recipient - this contract was set up in a
previous guide. Once that is done, 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.
In addition to the withdraw
function, there is the withdrawMax
function, which you can use to withdraw the maximum
amount of assets available in a stream at the time of invocation:
loading...
In effect, what withdrawMax
does is call the withdrawableAmountOf
function, and pass its result to withdraw
.
Lastly, there is the withdrawMultiple
function, with which you can withdraw from multiple streams at once:
loading...