Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Celer

Hierarchy

  • Celer

Index

Methods

approveErc20

  • approveErc20(tokenAddress: string): Promise<string>
  • Approves the CelerLedger contract to spend an ERC-20 token.

    Parameters

    • tokenAddress: string

      The token address

    Returns Promise<string>

close

  • close(): void
  • Closes the database connection. NOTE: Should be only used in tests.

    Returns void

confirmOutgoingPayment

  • confirmOutgoingPayment(paymentId: string): Promise<void>
  • Confirms an outgoing payment

    Parameters

    • paymentId: string

      The payment ID

    Returns Promise<void>

cooperativeWithdraw

  • cooperativeWithdraw(channelId: string, amount: string): Promise<string>
  • Cooperatively withdraw from a payment channel.

    Parameters

    • channelId: string

      The channel ID.

    • amount: string

      The amount to be withdrawn from the channel, in wei

    Returns Promise<string>

    The deposit transaction hash

deposit

  • deposit(channelId: string, tokenType: 0 | 2 | 1, amount: string): Promise<string>
  • Deposits into a payment channel.

    Parameters

    • channelId: string

      The channel ID.

    • tokenType: 0 | 2 | 1

      The token type, currently supporting ETH and ERC20

    • amount: string

      The amount to be deposited into the channel, in wei

    Returns Promise<string>

    The deposit transaction hash

generateHashLockCondition

  • generateHashLockCondition(): Promise<Condition>
  • Generates a and stores a hash lock condition for a payment.

    Returns Promise<Condition>

    A hash lock condition

getAllPaymentChannelIdsForToken

  • getAllPaymentChannelIdsForToken(tokenAddress: string): Promise<string[]>
  • Gets all payment channel IDs for a token

    Parameters

    • tokenAddress: string

      The token address

    Returns Promise<string[]>

    The payment channel IDs

getIncomingPaymentIds

  • getIncomingPaymentIds(channelId: string): Promise<string[]>
  • Gets the IDs of all incoming payments on a channel

    Parameters

    • channelId: string

      The channel ID

    Returns Promise<string[]>

    The list of IDs for all incoming payments

getOutgoingPaymentIds

  • getOutgoingPaymentIds(channelId: string): Promise<string[]>
  • Gets the IDs of all outgoing payments on a channel

    Parameters

    • channelId: string

      The channel ID

    Returns Promise<string[]>

    The list of IDs for all outgoing payments

getPaymentChannelInfo

getPaymentInfo

  • getPaymentInfo(paymentId: string): Promise<PaymentInfo>

openPaymentChannel

  • openPaymentChannel(tokenType: 0 | 2 | 1, tokenAddress: string, amount: string, peerAmount: string): Promise<string>
  • Opens a payment channel.

    Parameters

    • tokenType: 0 | 2 | 1

      The token type, currently supporting ETH and ERC20

    • tokenAddress: string

      The token address

    • amount: string

      The amount to be deposited into the channel, in wei

    • peerAmount: string

      The amount to be deposited into the channel by the counterparty, in wei

    Returns Promise<string>

    The channel ID

rejectIncomingPayment

  • rejectIncomingPayment(paymentId: string): Promise<void>
  • Rejects an incoming payment

    Parameters

    • paymentId: string

      The payment ID

    Returns Promise<void>

removeHashlockCondition

  • removeHashlockCondition(condition: Condition): Promise<void>
  • Removes a hash lock condition from storage.

    Parameters

    • condition: Condition

      A hash lock condition

    Returns Promise<void>

sendConditionalPayment

  • sendConditionalPayment(tokenType: 0 | 2 | 1, tokenAddress: string, destination: string, amount: string, transferFunctionType: 0 | 2 | 1 | 3 | 4 | 5, conditions: Condition[], timeout: number, note: Any): Promise<string>
  • Sends a conditional payment.

    Parameters

    • tokenType: 0 | 2 | 1

      The token type, currently supporting ETH and ERC20

    • tokenAddress: string

      The token address (only used for ERC20 payments)

    • destination: string

      The ETH address of the recipient

    • amount: string

      The amount to be sent, in wei

    • transferFunctionType: 0 | 2 | 1 | 3 | 4 | 5

      The type of the transfer logic. Currently only supporting BOOLEAN_AND

    • conditions: Condition[]

      The list of Condition objects

    • timeout: number

      The number of blocks after which the payment expires

    • note: Any

      An optional payment note with additional information for the recipient

    Returns Promise<string>

    The payment ID

sendPayment

  • sendPayment(tokenType: 0 | 2 | 1, tokenAddress: string, destination: string, amount: string, note?: Any): Promise<string>
  • Sends a payment with a single hash lock condition.

    Parameters

    • tokenType: 0 | 2 | 1

      The token type, currently supporting ETH and ERC20

    • tokenAddress: string

      The token address

    • destination: string

      The ETH address of the recipient

    • amount: string

      The amount to be sent, in wei

    • Optional note: Any

      An optional payment note with additional information for the recipient

    Returns Promise<string>

    The payment ID

Static create

  • create(connection: JsonRpcProvider | AsyncSendable | string, account: Signer | string | number, contractsInfo: ContractsInfo, config: Config): Promise<Celer>
  • Creates a Celer Light Client instance.

    Parameters

    • connection: JsonRpcProvider | AsyncSendable | string

      One of:

      • JsonRpcProvider instance
      • Metamask web3.currentProvider object
      • JSON-RPC connection URL

    • account: Signer | string | number

      One of:

      • Signer (Wallet)
      • Hex-encoded address of an account in the provider
      • Hex-encoded private key
      • Number index of an account loaded in the provider

    • contractsInfo: ContractsInfo

      The addresses of the Celer contracts

    • config: Config

      The configuration object

    Returns Promise<Celer>

Made by Horyus. Documentation generated by TypeDoc.