Drips docs

Drips docs

    ›Splitting

    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

    Edit User Splits

    To edit the Splits configuration for a NFTDriver-based sub-account, you will need to use the NFTDriver.setSplits method:

    setSplits(
        tokenId: string,
        receivers: SplitsReceiverStruct[])
    : Promise<ContractTransaction>
    

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

    To use this method you will first need to create a NFTDriverClient.

    You will also need to know the tokenId of the NFT-based sub-account you wish to setSplits for. You can find all of the sub-accounts owned by an Ethereum address, and their tokenIds, which are the same as their user IDs, by getting an account list for the address.

    Next you will need to build the new list of splits receivers that you want to set, as a SplitsReceiverStruct[] array. As part of building this array, you may wish to keep some of the Splits from the existing/previous configuration. To do this, use an instance of SubgraphClient to query the existing Splits configuration by calling SubgraphClient.getSplitsConfigByUserId:

    const currentSplitsConfiguration = await subgraphClient?.getSplitsConfigByUserId(userId);
    

    You can now build a new SplitsReceiverStruct[] array by combining as many of the existing SplitsReceiverStructs returned by getSplitsConfigByUserId with new SplitsReceiverStructs for new Splits you wish to create for the account

    Take a look at this code sample, which shows how you can do this with the help of some utility functions the SDK exposes, from some form inputs. If you would like to see this code sample in action, you can do so by running the NFTDriverClient examples app.

    Finally call the setSplits method to set the new Splits configuration for the account.

    ← Create User SplitsList User Splits →