Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AddressDriverClient

A client for managing Drips accounts identified by Ethereum addresses.

see

AddressDriver contract.

Hierarchy

  • AddressDriverClient

Index

Constructors

Properties

#driver: AddressDriver
#driverAddress: string
#provider: Provider
#signer: undefined | Signer
#txFactory: IAddressDriverTxFactory

Accessors

  • get driverAddress(): string
  • get provider(): Provider
  • get signer(): undefined | Signer
  • Returns the client's signer.

    Note that for read-only client instances created with the {@link createReadonly} method it returns undefined.

    Returns undefined | Signer

Methods

  • approve(tokenAddress: string): Promise<ContractTransaction>
  • Sets the maximum allowance value for the AddressDriver contract over the user's tokens for the given ERC20 token.

    throws

    {@link DripsErrors.addressError} if the tokenAddress is not valid.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • collect(tokenAddress: string, transferToAddress: string): Promise<ContractTransaction>
  • Collects the received and already split funds and transfers them from the DripsHub contract to an address.

    throws

    {@link DripsErrors.addressError} if tokenAddress or transferToAddress is not valid.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • transferToAddress: string

      The address to send collected funds to.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • emitUserMetadata(userMetadata: UserMetadata[]): Promise<ContractTransaction>
  • Emits the user's metadata. The key and the value are not standardized by the protocol, it's up to the user to establish and follow conventions to ensure compatibility with the consumers.

    throws

    {@link DripsErrors.argumentError} if any of the metadata entries is not valid.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • userMetadata: UserMetadata[]

      The list of user metadata. Note that a metadata key needs to be 32bytes.

      Tip: you might want to use Utils.UserMetadata.createFromStrings to easily create metadata instances from string inputs.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • getAllowance(tokenAddress: string): Promise<bigint>
  • Returns the remaining number of tokens the AddressDriver contract is allowed to spend on behalf of the user for the given ERC20 token.

    throws

    {@link DripsErrors.addressError} if the tokenAddress is not valid.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<bigint>

    A Promise which resolves to the remaining number of tokens.

  • getUserId(): Promise<string>
  • Returns the user user ID.

    This is the user ID to which the AddressDriverClient is linked and manages Drips.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Returns Promise<string>

    A Promise which resolves to the user ID.

  • getUserIdByAddress(userAddress: string): Promise<string>
  • Returns the user ID for a given address.

    throws

    {@link DripsErrors.addressError} if the userAddress address is not valid.

    Parameters

    • userAddress: string

      The user address.

    Returns Promise<string>

    A Promise which resolves to the user ID.

  • give(receiverUserId: string, tokenAddress: string, amount: BigNumberish): Promise<ContractTransaction>
  • Gives funds to the receiver. The receiver can collect them immediately. Transfers funds from the user's wallet to the DripsHub contract.

    throws

    {@link DripsErrors.argumentMissingError} if the receiverUserId is missing.

    throws

    {@link DripsErrors.addressError} if the tokenAddress is not valid.

    throws

    {@link DripsErrors.argumentError} if the amount is less than or equal to 0.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • receiverUserId: string

      The receiver user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • amount: BigNumberish

      The amount to give (in the smallest unit, e.g., Wei). It must be greater than 0.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • setDrips(tokenAddress: string, currentReceivers: DripsReceiverStruct[], newReceivers: DripsReceiverStruct[], transferToAddress: string, balanceDelta?: BigNumberish): Promise<ContractTransaction>
  • Sets a Drips configuration. Transfers funds from the user's wallet to the DripsHub contract to fulfill the change of the drips balance.

    throws

    {@link DripsErrors.addressError} if tokenAddress or transferToAddress is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if any of the required parameters is missing.

    throws

    {@link DripsErrors.argumentError} if currentReceivers' or newReceivers' count exceeds the max allowed drips receivers.

    throws

    {@link DripsErrors.dripsReceiverError} if any of the currentReceivers or the newReceivers is not valid.

    throws

    {@link DripsErrors.dripsReceiverConfigError} if any of the receivers' configuration is not valid.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • currentReceivers: DripsReceiverStruct[]

      The drips receivers that were set in the last drips update. Pass an empty array if this is the first update.

      Tip: you might want to use DripsSubgraphClient.getCurrentDripsReceivers to easily retrieve the list of current receivers.

    • newReceivers: DripsReceiverStruct[]

      The new drips receivers (max 100). Duplicate receivers are not allowed and will only be processed once. Pass an empty array if you want to clear all receivers.

    • transferToAddress: string

      The address to send funds to in case of decreasing balance.

    • balanceDelta: BigNumberish = 0

      The drips balance change to be applied:

      • Positive to add funds to the drips balance.
      • Negative to remove funds from the drips balance.
      • 0 to leave drips balance as is (default value).

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • Sets the Splits configuration.

    throws

    {@link DripsErrors.argumentMissingError} if receivers are missing.

    throws

    {@link DripsErrors.argumentError} if receivers' count exceeds the max allowed splits receivers.

    throws

    {@link DripsErrors.splitsReceiverError} if any of the receivers is not valid.

    throws

    {@link DripsErrors.signerMissingError} if the provider's signer is missing.

    Parameters

    • receivers: SplitsReceiverStruct[]

      The splits receivers (max 200). Each splits receiver will be getting weight / TOTAL_SPLITS_WEIGHT share of the funds. Duplicate receivers are not allowed and will only be processed once. Pass an empty array if you want to clear all receivers.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • create(provider: Provider, signer?: Signer, customDriverAddress?: string): Promise<AddressDriverClient>
  • create(provider: Provider, signer?: Signer, customDriverAddress?: string, txFactory?: IAddressDriverTxFactory): Promise<AddressDriverClient>
  • Creates a new immutable AddressDriverClient instance.

    throws

    {@link DripsErrors.initializationError} if the client initialization fails.

    Parameters

    • provider: Provider

      The network provider. It cannot be changed after creation.

      The provider must be connected to one of the following supported networks:

      • 'mainnet': chain ID 1
      • 'goerli': chain ID 5
      • 'polygon-mumbai': chain ID 80001
    • Optional signer: Signer

      The singer used to sign transactions. It cannot be changed after creation.

      Important: If the signer is not connected to a provider it will try to connect to the provider, else it will use the signer.provider.

    • Optional customDriverAddress: string

      Overrides the AddressDriver contract address. If it's undefined (default value), the address will be automatically selected based on the provider's network.

    Returns Promise<AddressDriverClient>

    A Promise which resolves to the new client instance.

  • Parameters

    • provider: Provider
    • Optional signer: Signer
    • Optional customDriverAddress: string
    • Optional txFactory: IAddressDriverTxFactory

    Returns Promise<AddressDriverClient>

  • getUserAddress(userId: string): string

Generated using TypeDoc