Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Raiden

Hierarchy

  • Raiden

Index

Constructors

constructor

  • Constructs a Raiden instance from state machine parameters

    It expects ready Redux and Epics params, with some async members already resolved and set in place, therefore this constructor is expected to be used only for tests and advancecd usage where finer control is needed to tweak how some of these members are initialized; Most users should usually prefer the create async factory, which already takes care of these async initialization steps and accepts more common parameters.

    Parameters

    • state: RaidenState

      Validated and decoded initial/rehydrated RaidenState

    • deps: RaidenEpicDeps

      Constructed epics dependencies object, including signer, provider, fetched network and contracts information.

    • epic: RaidenEpic = ...

      State machine root epic

    • reducer: (state?: RaidenState, action: RaidenAction) => RaidenState = ...

      State machine root reducer

        • Raiden root reducer Apply action over each submodule root reducer in a flattened manner (iteratively). Notice the submodules reducers aren't handled only a partial/deep property of the state (as combineReducers), but instead receive the whole state, so they can act on any part of the state. This approach is similar to reduce-reducers util. Each submodule root reducer may then choose to split its concerns into nested or flattened reducers (like this one).

          Parameters

          Returns RaidenState

          New RaidenState

    Returns Raiden

Properties

Readonly action$

action$: Observable<RaidenAction> = ...

action$ exposes the internal events pipeline. It's intended for debugging, and its interface must not be relied on, as its actions interfaces and structures can change without warning.

blockTime$

blockTime$: Observable<number> = ...

Observable of latest average (10) block times

Readonly channels$

channels$: Observable<RaidenChannels> = ...

channels$ is public interface, exposing a view of the currently known channels Its format is expected to be kept backwards-compatible, and may be relied on

config

config: RaidenConfig

RaidenConfig object

config$

config$: Observable<RaidenConfig> = ...

RaidenConfig observable (for reactive use)

Readonly events$

events$: Observable<RaidenEvent> = ...

A subset ot RaidenActions exposed as public events. The interface of the objects emitted by this Observable are expected not to change internally, but more/new events may be added over time.

getTokenInfo

getTokenInfo: (token: string) => Promise<{ decimals: number; name?: string; symbol?: string; totalSupply: BigNumber }> = ...

Get constant token details from token contract, caches it. Rejects only if 'token' contract doesn't define totalSupply and decimals methods. name and symbol may be undefined, as they aren't actually part of ERC20 standard, although very common and defined on most token contracts.

Type declaration

    • (token: string): Promise<{ decimals: number; name?: string; symbol?: string; totalSupply: BigNumber }>
    • Get constant token details from token contract, caches it. Rejects only if 'token' contract doesn't define totalSupply and decimals methods. name and symbol may be undefined, as they aren't actually part of ERC20 standard, although very common and defined on most token contracts.

      Parameters

      • token: string

        address to fetch info from

      Returns Promise<{ decimals: number; name?: string; symbol?: string; totalSupply: BigNumber }>

      Memoized function to fetch token info

Readonly resolveName

resolveName: (name: string) => Promise<Address> = ...

Type declaration

    • Expose ether's Provider.resolveName for ENS support

      Parameters

      • name: string

      Returns Promise<Address>

Readonly state$

state$: Observable<RaidenState> = ...

state$ is exposed only so user can listen to state changes and persist them somewhere else. Format/content of the emitted objects are subject to changes and not part of the public API

synced

synced: Promise<undefined | { currentBlock: number; initialBlock: number; tookMs: number }> = ...

When started, is set to a promise which resolves when node finishes syncing

Readonly transfers$

transfers$: Observable<RaidenTransfer> = ...

Observable of completed and pending transfers Every time a transfer state is updated, it's emitted here. 'key' property is unique and may be used as identifier to know which transfer got updated.

userDepositTokenAddress

userDepositTokenAddress: () => Promise<Address> = ...

The address of the token that is used to pay the services (SVT/RDN).

Type declaration

    • The address of the token that is used to pay the services (SVT/RDN).

      Returns Promise<Address>

Accessors

address

  • Get current account address (subkey's address, if subkey is being used)

    Returns Address

    Instance address

contractsInfo

  • get contractsInfo(): Readonly<{ MonitoringService: any; OneToN: any; SecretRegistry: any; ServiceRegistry: any; TokenNetworkRegistry: any; UserDeposit: any }>
  • Returns the Smart Contracts addresses and deployment blocks

    Returns Readonly<{ MonitoringService: any; OneToN: any; SecretRegistry: any; ServiceRegistry: any; TokenNetworkRegistry: any; UserDeposit: any }>

    Smart Contracts info

log

  • get log(): Logger
  • Instance's Logger, compatible with console's API

    Returns Logger

    Logger object

mainAddress

  • get mainAddress(): undefined | Address
  • Get main account address (if subkey is being used, undefined otherwise)

    Returns undefined | Address

    Main account address

network

  • get network(): Network
  • Get current network from provider

    Returns Network

    Network object containing blockchain's name & chainId

provider

  • get provider(): JsonRpcProvider
  • Current provider getter

    Returns JsonRpcProvider

    ether's provider instance

settleTimeout

  • get settleTimeout(): number
  • Fetches contract's settleTimeout

    Returns number

    settleTimeout constant value from contracts

started

  • get started(): undefined | boolean
  • Gets the running state of the instance

    Returns undefined | boolean

    undefined if not yet started, true if running, false if already stopped

state

  • Get current RaidenState object. Can be serialized safely with [[encodeRaidenState]]

    Returns RaidenState

    Current Raiden state

Static contractVersion

  • get contractVersion(): string
  • Returns the version of the used Smart Contracts.

    Returns string

    Smart Contract version

Static version

  • get version(): string
  • Returns the currently used SDK version.

    Returns string

    SDK version

Methods

closeChannel

  • closeChannel(token: string, partner: string): Promise<Hash>
  • Close channel between us and partner on tokenNetwork for token This method will fail if called on a channel not in 'opened' or 'closing' state. When calling this method on an 'opened' channel, its state becomes 'closing', and from there on, no payments can be performed on the channel. If for any reason the closeChannel transaction fails, channel's state stays as 'closing', and this method can be called again to retry sending 'closeChannel' transaction. After it's successful, channel becomes 'closed', and can be settled after 'settleTimeout' seconds (when it then becomes 'settleable').

    Parameters

    • token: string

      Token address on currently configured token network registry

    • partner: string

      Partner address

    Returns Promise<Hash>

    txHash of closeChannel call, iff it succeeded

depositChannel

  • depositChannel(token: string, partner: string, amount: BigNumberish, __namedParameters?: { confirmConfirmation?: boolean }): Promise<Hash>
  • Deposit tokens on channel between us and partner on tokenNetwork for token

    Parameters

    • token: string

      Token address on currently configured token network registry

    • partner: string

      Partner address

    • amount: BigNumberish

      Number of tokens to deposit on channel

    • __namedParameters: { confirmConfirmation?: boolean } = {}
      • Optional confirmConfirmation?: boolean

    Returns Promise<Hash>

    txHash of setTotalDeposit call, iff it succeeded

depositToUDC

  • Deposits the amount to the UserDeposit contract with the target/signer as a beneficiary. The deposited amount can be used as a collateral in order to sign valid IOUs that will be accepted by the Services.

    Throws an error, in the following cases:

    1. The amount specified equals to zero
    2. The target has an insufficient token balance
    3. The "approve" transaction fails with an error
    4. The "deposit" transaction fails with an error

    Parameters

    • amount: BigNumberish

      The amount to deposit on behalf of the target/beneficiary.

    • Optional onChange: OnChange<EventTypes, { txHash: string }>

      callback providing notifications about state changes

    Returns Promise<Hash>

    transaction hash

directRoute

  • directRoute(token: string, target: string, value: BigNumberish): Promise<undefined | readonly Readonly<{ fee: Int<32>; path: readonly Address[] } & { address_metadata: undefined | Readonly<{}> }>[]>
  • Checks if a direct transfer of token to target could be performed and returns it on a single-element array of Paths

    Parameters

    • token: string

      Token address on currently configured token network registry

    • target: string

      Target address

    • value: BigNumberish

      Minimum capacity required on route

    Returns Promise<undefined | readonly Readonly<{ fee: Int<32>; path: readonly Address[] } & { address_metadata: undefined | Readonly<{}> }>[]>

    Promise to a [Raiden]Paths array containing the single, direct route, or undefined

dumpDatabase

  • dumpDatabase(): AsyncGenerator<RaidenDatabaseMeta | Omit<ExistingDocument<AllDocsMeta>, "_rev">, void, undefined>
  • Dumps database content for backup

    yields

    Rows of objects

    Returns AsyncGenerator<RaidenDatabaseMeta | Omit<ExistingDocument<AllDocsMeta>, "_rev">, void, undefined>

findPFS

  • findPFS(): Promise<PFS[]>
  • Returns a sorted array of info of available PFS

    It uses data polled from ServiceRegistry, which is available only when config.pfs is undefined, instead of set or disabled (null), and will reject if not. It can reject if the validated list is empty, meaning we can be out-of-sync (we're outdated or they are) with PFSs deployment, or no PFS is available on this TokenNetwork/blockchain.

    Returns Promise<PFS[]>

    Promise to array of PFS, which is the interface which describes a PFS

findRoutes

  • findRoutes(token: string, target: string, value: BigNumberish, options?: { pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number } }): Promise<readonly Readonly<{ fee: Int<32>; path: readonly Address[] } & { address_metadata: undefined | Readonly<{}> }>[]>
  • Request a path from PFS

    If a direct route is possible, it'll be returned. Else if PFS is set up, a request will be performed and the cleaned/validated path results will be resolved. Else, if no route can be found, promise is rejected with respective error.

    Parameters

    • token: string

      Token address on currently configured token network registry

    • target: string

      Target address

    • value: BigNumberish

      Minimum capacity required on routes

    • options: { pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number } } = {}

      Optional parameters

      • Optional pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number }

        Use this PFS instead of configured or automatically choosen ones

        • address: string
        • matrixServer: string
        • price: BigNumberish
        • rtt: number
        • token: string
        • url: string
        • validTill: number

    Returns Promise<readonly Readonly<{ fee: Int<32>; path: readonly Address[] } & { address_metadata: undefined | Readonly<{}> }>[]>

    A promise to returned routes/paths result

getAvailability

  • getAvailability(address: string): Promise<{ available: boolean; ts: number; userId: string }>
  • Returns object describing address's users availability on transport After calling this method, any further presence update to valid transport peers of this address will trigger a corresponding MatrixPresenceUpdateAction on events$

    Parameters

    • address: string

      checksummed address to be monitored

    Returns Promise<{ available: boolean; ts: number; userId: string }>

    Promise to object describing availability and last event timestamp

getBalance

  • getBalance(address?: string): Promise<BigNumber>
  • Get ETH balance for given address or self

    Parameters

    • Optional address: string

      Optional target address. If omitted, gets own balance

    Returns Promise<BigNumber>

    BigNumber of ETH balance

getBlockNumber

  • getBlockNumber(): Promise<number>
  • Returns a promise to current block number, as seen in provider and state

    Returns Promise<number>

    Promise to current block number

getTokenBalance

  • getTokenBalance(token: string, address?: string): Promise<BigNumber>
  • Get token balance and token decimals for given address or self

    Parameters

    • token: string

      Token address to fetch balance. Must be one of the monitored tokens.

    • Optional address: string

      Optional target address. If omitted, gets own balance

    Returns Promise<BigNumber>

    BigNumber containing address's token balance

getTokenList

  • getTokenList(rescan?: boolean): Promise<Address[]>
  • Returns a list of all token addresses registered as token networks in registry

    Parameters

    • rescan: boolean = false

      Whether to rescan events from scratch

    Returns Promise<Address[]>

    Promise to list of token addresses

getTransfers

  • getTransfers(filter?: { end?: string; partner?: string; pending?: boolean; token?: string }, options?: { desc?: boolean; limit?: number; offset?: number }): Promise<RaidenTransfer[]>
  • Get list of past and pending transfers

    Parameters

    • Optional filter: { end?: string; partner?: string; pending?: boolean; token?: string }

      Filter options

      • Optional end?: string

        filter by initiator or target address

      • Optional partner?: string

        filter by partner address

      • Optional pending?: boolean

        true: only pending; false: only completed; undefined: all

      • Optional token?: string

        filter by token address

    • Optional options: { desc?: boolean; limit?: number; offset?: number }

      PouchDB.ChangesOptions object

      • Optional desc?: boolean

        Set to true to get newer transfers first

      • Optional limit?: number

        Limit number of entries

      • Optional offset?: number

        Offset to skip entries

    Returns Promise<RaidenTransfer[]>

    promise to array of all transfers

getUDCCapacity

  • getUDCCapacity(): Promise<BigNumber>
  • Fetches balance of UserDeposit Contract for SDK's account minus cached spent IOUs

    Returns Promise<BigNumber>

    Promise to UDC remaining capacity

getUDCTotalDeposit

  • getUDCTotalDeposit(): Promise<BigNumber>
  • Fetches total_deposit of UserDeposit Contract for SDK's account

    The usable part of the deposit should be fetched with getUDCCapacity, but this function is useful when trying to deposit based on the absolute value of totalDeposit.

    Returns Promise<BigNumber>

    Promise to UDC total deposit

getUDCWithdrawPlan

  • getUDCWithdrawPlan(): Promise<undefined | { amount: UInt<32>; ready: boolean; withdrawableAfter: number }>
  • Fetches our current UDC withdraw plan

    Returns Promise<undefined | { amount: UInt<32>; ready: boolean; withdrawableAfter: number }>

    Promise to object containing maximum 'amount' planned for withdraw and 'withdrawableAfter' second at which withdraw will become available, and 'ready' after it can be withdrawn with withdrawFromUDC; resolves to undefined if there's no current plan

mint

  • mint(token: string, amount: BigNumberish, __namedParameters?: { to?: string }): Promise<Hash>
  • Mints the amount of tokens of the provided token address. Throws an error, if

    1. Executed on main net
    2. `token` or `options.to` is not a valid address
    3. Token could not be minted

    Parameters

    • token: string

      Address of the token to be minted

    • amount: BigNumberish

      Amount to be minted

    • __namedParameters: { to?: string } = {}
      • Optional to?: string

    Returns Promise<Hash>

    transaction

monitorToken

  • monitorToken(token: string): Promise<Address>
  • Scans initially and start monitoring a token for channels with us, returning its Tokennetwork address

    Throws an exception if token isn't registered in current registry

    Parameters

    • token: string

      token address to monitor, must be registered in current token network registry

    Returns Promise<Address>

    Address of TokenNetwork contract

openChannel

  • openChannel(token: string, partner: string, options?: { confirmConfirmation?: boolean; deposit?: BigNumberish }, onChange?: OnChange<EventTypes, { txHash: string }>): Promise<Hash>
  • Open a channel on the tokenNetwork for given token address with partner

    If token isn't yet monitored, starts monitoring it

    Parameters

    • token: string

      Token address on currently configured token network registry

    • partner: string

      Partner address

    • options: { confirmConfirmation?: boolean; deposit?: BigNumberish } = {}

      (optional) option parameter

      • Optional confirmConfirmation?: boolean

        Whether to wait confirmationBlocks after last transaction confirmation; default=true if confirmationBlocks

      • Optional deposit?: BigNumberish

        Deposit to perform in parallel with channel opening

    • Optional onChange: OnChange<EventTypes, { txHash: string }>

      Optional callback for status change notification

    Returns Promise<Hash>

    txHash of channelOpen call, iff it succeeded

planUDCWithdraw

  • planUDCWithdraw(value?: BigNumberish): Promise<Hash>
  • Records a UDC withdraw plan for our UDC deposit, capped at whole balance.

    Parameters

    • value: BigNumberish = ...

      Maximum value which we may try to withdraw.

    Returns Promise<Hash>

    Promise to hash of plan transaction, if it succeeds.

registerToken

  • registerToken(token: string, channelParticipantDepositLimit?: BigNumberish, tokenNetworkDepositLimit?: BigNumberish): Promise<Address>
  • Registers and creates a new token network for the provided token address. Throws an error, if

    1. Executed on main net
    2. `token` is not a valid address
    3. Token is already registered
    4. Token could not be registered

    Parameters

    • token: string

      Address of the token to be registered

    • channelParticipantDepositLimit: BigNumberish = ...

      The deposit limit per channel participant

    • tokenNetworkDepositLimit: BigNumberish = ...

      The deposit limit of the whole token network

    Returns Promise<Address>

    Address of new token network

settleChannel

  • settleChannel(token: string, partner: string): Promise<Hash>
  • Settle channel between us and partner on tokenNetwork for token This method will fail if called on a channel not in 'settleable' or 'settling' state. Channel becomes 'settleable' settleTimeout seconds after closed (detected automatically while Raiden Light Client is running or later on restart). When calling it, channel state becomes 'settling'. If for any reason transaction fails, it'll stay on this state, and this method can be called again to re-send a settleChannel transaction.

    Parameters

    • token: string

      Token address on currently configured token network registry

    • partner: string

      Partner address

    Returns Promise<Hash>

    txHash of settleChannel call, iff it succeeded

start

  • start(): Promise<void>
  • Starts redux/observables by subscribing to all epics and emitting initial state and action

    No event should be emitted before start is called

    Returns Promise<void>

stop

  • stop(): Promise<void>
  • Triggers all epics to be unsubscribed

    Returns Promise<void>

suggestPartners

  • suggestPartners(token: string, options?: { pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number } }): Promise<SuggestedPartner[]>
  • Fetches an ordered list of suggested partners from provided, configured or first found PFS

    Parameters

    • token: string

      Token address to get partners for

    • options: { pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number } } = {}

      Request options

      • Optional pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number }

        PFS to use, instead of configured or automatic

        • address: string
        • matrixServer: string
        • price: BigNumberish
        • rtt: number
        • token: string
        • url: string
        • validTill: number

    Returns Promise<SuggestedPartner[]>

    Ordered array of suggested partners, with address and scoring values according to PFS

transfer

  • transfer(token: string, target: string, value: BigNumberish, options?: { encryptSecret?: boolean; lockTimeout?: number; paths?: readonly ({ address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; fee: BigNumberish; route: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; estimated_fee: BigNumberish; route: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; fee: BigNumberish; path: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; estimated_fee: BigNumberish; path: readonly string[] })[]; paymentId?: BigNumberish; pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number }; secret?: string; secrethash?: string }): Promise<string>
  • Send a Locked Transfer! This will reject if LockedTransfer signature prompt is canceled/signature fails, or be resolved to the transfer unique identifier (secrethash) otherwise, and transfer status can be queried with this id on this.transfers$ observable, which will just have emitted the 'pending' transfer. Any following transfer state change will be notified through this observable.

    Parameters

    • token: string

      Token address on currently configured token network registry

    • target: string

      Target address

    • value: BigNumberish

      Amount to try to transfer

    • options: { encryptSecret?: boolean; lockTimeout?: number; paths?: readonly ({ address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; fee: BigNumberish; route: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; estimated_fee: BigNumberish; route: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; fee: BigNumberish; path: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; estimated_fee: BigNumberish; path: readonly string[] })[]; paymentId?: BigNumberish; pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number }; secret?: string; secrethash?: string } = {}

      Optional parameters for transfer:

      • Optional encryptSecret?: boolean

        Whether to force encrypting the secret or not, if target supports it

      • Optional lockTimeout?: number

        Specify a lock timeout for transfer; default is expiryFactor * revealTimeout

      • Optional paths?: readonly ({ address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; fee: BigNumberish; route: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; estimated_fee: BigNumberish; route: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; fee: BigNumberish; path: readonly string[] } | { address_metadata: undefined | { [x: string]: { readonly user_id: string; readonly displayname: string; readonly capabilities: string; }; }; estimated_fee: BigNumberish; path: readonly string[] })[]

        Used to specify possible routes & fees instead of querying PFS. Should receive a decodable super-set of the public RaidenPaths interface

      • Optional paymentId?: BigNumberish

        payment identifier, a random one will be generated if missing

      • Optional pfs?: { address: string; matrixServer: string; price: BigNumberish; rtt: number; token: string; url: string; validTill: number }

        Use this PFS instead of configured or automatically choosen ones. Is ignored if paths were already provided. If neither are set and config.pfs is not disabled (null), use it if set or if undefined (auto mode), fetches the best PFS from ServiceRegistry and automatically fetch routes from it.

        • address: string
        • matrixServer: string
        • price: BigNumberish
        • rtt: number
        • token: string
        • url: string
        • validTill: number
      • Optional secret?: string

        Secret to register, a random one will be generated if missing

      • Optional secrethash?: string

        Must match secret, if both provided, or else, secret must be informed to target by other means, and reveal can't be performed

    Returns Promise<string>

    A promise to transfer's unique key (id) when it's accepted

transferOnchainBalance

  • transferOnchainBalance(to: string, value?: BigNumberish, __namedParameters?: { gasPrice?: BigNumberish; subkey?: boolean }): Promise<Hash>
  • Transfer value ETH on-chain to address. If subkey is being used, use main account by default, or subkey account if 'subkey' is true Example: // transfer 0.1 ETH from main account to subkey account, when subkey is used await raiden.transferOnchainBalance(raiden.address, parseEther('0.1')); // transfer entire balance from subkey account back to main account await raiden.transferOnchainBalance(raiden.mainAddress, undefined, { subkey: true });

    Parameters

    • to: string

      Recipient address

    • value: BigNumberish = ...

      Amount of ETH (in Wei) to transfer. Use ethers/utils::parseEther if needed Defaults to a very big number, which will cause all entire balance to be transfered

    • __namedParameters: { gasPrice?: BigNumberish; subkey?: boolean } = {}
      • Optional gasPrice?: BigNumberish
      • Optional subkey?: boolean

    Returns Promise<Hash>

    transaction hash

transferOnchainTokens

  • transferOnchainTokens(token: string, to: string, value?: BigNumberish, __namedParameters?: { subkey?: boolean }): Promise<Hash>
  • Transfer value tokens on-chain to address. If subkey is being used, use main account by default, or subkey account if 'subkey' is true

    Parameters

    • token: string

      Token address

    • to: string

      Recipient address

    • value: BigNumberish = ...

      Amount of tokens (in Wei) to transfer. Use ethers/utils::parseUnits if needed Defaults to a very big number, which will cause all entire balance to be transfered

    • __namedParameters: { subkey?: boolean } = {}
      • Optional subkey?: boolean

    Returns Promise<Hash>

    transaction hash

updateConfig

  • updateConfig(config: PartialRaidenConfig): void
  • Update Raiden Config with a partial (shallow) object

    Parameters

    • config: PartialRaidenConfig

      Partial object containing keys and values to update in config

    Returns void

waitTransfer

  • Waits for the transfer identified by a secrethash to fail or complete The returned promise will resolve with the final transfer state, or reject if anything fails

    Parameters

    • transferKey: string

      Transfer identifier as returned by transfer

    Returns Promise<RaidenTransfer>

    Promise to final RaidenTransfer

withdrawChannel

  • withdrawChannel(token: string, partner: string, amount?: BigNumberish): Promise<Hash>
  • Requests to withdraw from channel

    The requested amount defaults to the maximum withdrawable amount, which is exposed in channels$ observable as the RaidenChannel.ownWithdrawable member. This involves requesting partner a signature which confirms they agree that we have the right for this amount of tokens, then a transaction is sent on-chain to withdraw tokens to the effective account. If this process fails, the amount remains locked until it can be expired later (defaults to config.expiryFactory * config.revealTimeout seconds).

    Parameters

    • token: string

      Token address on currently configured token network registry

    • partner: string

      Partner address

    • Optional amount: BigNumberish

      Amount of tokens (in wei) to withdraw, must be between 1 and ownWithdrawable

    Returns Promise<Hash>

    Promise to the hash of the mined withdraw transaction

withdrawFromUDC

  • withdrawFromUDC(value?: BigNumberish, options?: { subkey?: boolean }): Promise<Hash>
  • Complete a planned UDC withdraw and get the deposit to account.

    Maximum 'value' is the one from current plan, attempting to withdraw a larger value will throw an error, but a smaller value is valid. This method may only be called after plan is 'ready'

    Parameters

    • Optional value: BigNumberish

      Maximum value which we may try to withdraw. An error will be thrown if this value is larger than getUDCCapacity+getUDCWithdrawPlan.amount

    • Optional options: { subkey?: boolean }

      options object

      • Optional subkey?: boolean

        if true, force withdrawing to subkey instead of the main account as beneficiary

    Returns Promise<Hash>

    Promise to hash of plan transaction, if it succeeds.

Static create

  • create<R>(connection: string | JsonRpcProvider | ExternalProvider, account: string | number | Signer, storage?: { adapter?: any; prefix?: string; state?: any }, contractsOrUDCAddress?: string | Readonly<{ MonitoringService: any; OneToN: any; SecretRegistry: any; ServiceRegistry: any; TokenNetworkRegistry: any; UserDeposit: any }>, config?: { additionalServices: undefined | readonly string[]; autoSettle: undefined | boolean; autoUDCWithdraw: undefined | boolean; caps: undefined | null | { [x: string]: string | number | boolean | (string | number | boolean | null)[] | null; }; confirmationBlocks: undefined | number; encryptSecret: undefined | boolean; expiryFactor: undefined | number; fallbackIceServers: undefined | { urls: string | string[]; }[]; gasPriceFactor: undefined | null | number; httpTimeout: undefined | number; logger: undefined | string; matrixServer: undefined | string; matrixServerLookup: undefined | string; mediationFees: unknown; minimumAllowance: undefined | BigNumberish; monitoringReward: undefined | null | BigNumberish; pfsIouTimeout: undefined | number; pfsMaxFee: undefined | BigNumberish; pfsMaxPaths: undefined | number; pfsMode: undefined | string; pfsSafetyMargin: undefined | number | [number, number]; pollingInterval: undefined | number; rateToSvt: undefined | { [x: string]: BigNumberish; }; revealTimeout: undefined | number; subkey: undefined | boolean }, subkey?: true, subkeyOriginUrl?: string): Promise<InstanceType<R>>
  • Async helper factory to make a Raiden instance from more common parameters.

    An async factory is needed so we can do the needed async requests to construct the required parameters ahead of construction time, and avoid partial initialization then

    Type parameters

    Parameters

    • connection: string | JsonRpcProvider | ExternalProvider

      A URL or provider to connect to, one of:

      • JsonRpcProvider instance,
      • a Metamask's web3.currentProvider object or,
      • a hostname or remote json-rpc connection string

    • account: string | number | Signer

      An account to use as main account, one of:

      • Signer instance (e.g. Wallet) loaded with account/private key or
      • hex-encoded string address of a remote account in provider or
      • hex-encoded string local private key or
      • number index of a remote account loaded in provider (e.g. 0 for Metamask's loaded account)

    • Optional storage: { adapter?: any; prefix?: string; state?: any }

      diverse storage related parameters to load from and save to

      • Optional adapter?: any

        PouchDB adapter; default to 'indexeddb' on browsers and 'leveldb' on node. If you provide a custom one, ensure you call PouchDB.plugin on it.

      • Optional prefix?: string

        Database name prefix; use to set a directory to store leveldown db;

      • Optional state?: any

        State uploaded by user; should be decodable by RaidenState; it is auto-migrated

    • Optional contractsOrUDCAddress: string | Readonly<{ MonitoringService: any; OneToN: any; SecretRegistry: any; ServiceRegistry: any; TokenNetworkRegistry: any; UserDeposit: any }>

      Contracts deployment info, or UserDeposit contract address

    • Optional config: { additionalServices: undefined | readonly string[]; autoSettle: undefined | boolean; autoUDCWithdraw: undefined | boolean; caps: undefined | null | { [x: string]: string | number | boolean | (string | number | boolean | null)[] | null; }; confirmationBlocks: undefined | number; encryptSecret: undefined | boolean; expiryFactor: undefined | number; fallbackIceServers: undefined | { urls: string | string[]; }[]; gasPriceFactor: undefined | null | number; httpTimeout: undefined | number; logger: undefined | string; matrixServer: undefined | string; matrixServerLookup: undefined | string; mediationFees: unknown; minimumAllowance: undefined | BigNumberish; monitoringReward: undefined | null | BigNumberish; pfsIouTimeout: undefined | number; pfsMaxFee: undefined | BigNumberish; pfsMaxPaths: undefined | number; pfsMode: undefined | string; pfsSafetyMargin: undefined | number | [number, number]; pollingInterval: undefined | number; rateToSvt: undefined | { [x: string]: BigNumberish; }; revealTimeout: undefined | number; subkey: undefined | boolean }

      Raiden configuration

      • additionalServices: undefined | readonly string[]
      • autoSettle: undefined | boolean
      • autoUDCWithdraw: undefined | boolean
      • caps: undefined | null | { [x: string]: string | number | boolean | (string | number | boolean | null)[] | null; }
      • confirmationBlocks: undefined | number
      • encryptSecret: undefined | boolean
      • expiryFactor: undefined | number
      • fallbackIceServers: undefined | { urls: string | string[]; }[]
      • gasPriceFactor: undefined | null | number
      • httpTimeout: undefined | number
      • logger: undefined | string
      • matrixServer: undefined | string
      • matrixServerLookup: undefined | string
      • mediationFees: unknown
      • minimumAllowance: undefined | BigNumberish
      • monitoringReward: undefined | null | BigNumberish
      • pfsIouTimeout: undefined | number
      • pfsMaxFee: undefined | BigNumberish
      • pfsMaxPaths: undefined | number
      • pfsMode: undefined | string
      • pfsSafetyMargin: undefined | number | [number, number]
      • pollingInterval: undefined | number
      • rateToSvt: undefined | { [x: string]: BigNumberish; }
      • revealTimeout: undefined | number
      • subkey: undefined | boolean
    • Optional subkey: true

      Whether to use a derived subkey or not

    • Optional subkeyOriginUrl: string

      URL of origin to generate a subkey for (defaults to global context)

    Returns Promise<InstanceType<R>>

    Promise to Raiden SDK client instance

Generated using TypeDoc