Drips docs

Drips docs

    ›Accounts

    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

    Add Funds

    To add funds to an NFT-based sub-account you will first need to create a NFTDriverClient and a DripsSubgraphClient.

    You can then add funds to the account by calling NFTDriverClient.setDrips with a positive value for the balanceDelta parameter. The value of the balanceDelta parameter will be the amount of funds that you add (or withdraw, in case of a negative value) from the account's streaming balance.

    The full signature of the setDrips method looks like this:

    setDrips(
        tokenId: string, 
        tokenAddress: string, 
        currentReceivers: DripsReceiverStruct[], 
        newReceivers: DripsReceiverStruct[], 
        transferToAddress: string, 
        balanceDelta?: BigNumberish
        )
    : Promise<ContractTransaction>
    

    Take a look at this method's documentation to understand what each parameter represents.

    Initially it may be somewhat unintuitive that you would need to call setDrips() to simply add or withdraw funds from an account's streaming balance. However, it makes sense when you consider the fact that making a change to the streaming balance will cause the DripsHub contract to recalculate the new end times (i.e. when they will run out of funds) of any Drips that the account has configured. Moreover, because DripsHub doesn't store the full receivers lists on-chain, for gas-optimization, it makes sense that we would need to pass them in again when we make any change to the streaming balance.

    With this in mind, you'll need to have the list of current receivers in order to update the Drips configuration. You can get the current receivers by calling:

    const currentDripsConfiguration =
        await subgraphClient.getUserAssetConfigById(configuredUserId, assetId);
    const currentReceivers = currentDripsConfiguration.dripsEntries || [];
    

    Finally call the setDrips method, with a value of balanceDelta equal to the quantity of tokens you would like to add (or withdraw) to/from the account's streaming balance.

    ← List Sub-AccountsStart a Stream →