Drips docs

Drips docs

    ›Streams

    Intro and Basics

    • What's a Drip?
    • Drips v2 Features
    • Accessing Drips
    • FAQ

    The Drips App

    • Getting Started
    • Manage funds

      • Add funds
      • Withdraw funds
      • Collect earnings

      Streams

      • Create a stream
      • Edit, pause or delete a stream

      Splits

      • Set up & manage splits

      Explore the network

      • Drips profiles

      Advanced

      • Connecting to a Safe

    The Protocol

    • Overview
    • User Identities In Drips
    • Smart Contract and Subgraph Details
    • Security

    For Developers

    • The Drips JS SDK
    • Installing the SDK and Running the Example App
    • Initializing the SDK
    • Accounts

      • Intro to Accounts
      • Create an Account
      • List Sub-Accounts
      • Add Funds

      Streams

      • Start a Stream
      • Update a Stream
      • Scheduling

      Splitting

      • Create User Splits
      • Edit User Splits
      • List User Splits
      • Immutable Splits

      Collecting

      • How to Collect
      • Squeezing Drips

      Advanced Topics

      • Caller
      • Account Metadata
      • Dripping Fractional Amounts
      • Drips inner workings

    Get Involved

    • Join the Drips Community

    Scheduling

    One of the most powerful features of Drips V2 is the ability for users to schedule streams. This means that when users or apps create new Drips, they can optionally assign startTime and duration parameters, which allow them to define when the Drip should start and end in time.

    Let's take a look at DripsReceiverStruct to see how this works in more detail:

    DripsReceiverStruct: { 
        config: PromiseOrValue<BigNumberish>;
        userId: PromiseOrValue<BigNumberish> 
        }
    

    We can see that a DripsReceiverStruct contains two values: (1) a "config" variable and (2) the userId that will be the recipient of the stream.

    The "config" variable is actually a singlie field which is used to encode a number of other variables into a single number. We can see how this works by taking a look at DripsReceiverConfig, which shows all of the variables that are part of a config value:

    DripsReceiverConfig: {
        amountPerSec: bigint;
        dripId: bigint;
        duration: bigint;
        start: bigint
    }
    

    The SDK provides some helpful utility functions to help with converting DripsReceiverConfig structs to and from single-integer-encoded values. Take a look at Utils.toUint256 and Utils.fromUint256 to see how they work.

    And to see a complete example of how these types and functions can be used to encode a configuration with a startTime and duration and schedule a Drip in practice, have a look at the relevant section of the setDrips() function from the example app.

    When scheduling Drips, one thing to consider is that the block time when your transaction is executed makes a difference. In particular, if you call NFTDriverClient.setDrips() with a startTime earlier than the block time when the transaction is executed, the new Drip will only start from the block time when the transaction was executed, not the time that you specified.

    Therefore, if it is imporant to you that your Drip starts exactly on-schedule at startTime, always make sure that the transaction containing the setDrips() call is executed well before that time.

    ← Update a StreamCreate User Splits →