Validated and decoded initial/rehydrated RaidenState
Constructed epics dependencies object, including signer, provider, fetched network and contracts information.
State machine root epic
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).
Current RaidenState to reduce
RaidenAction to apply over state
New RaidenState
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.
Observable of latest average (10) block times
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
RaidenConfig object
RaidenConfig observable (for reactive use)
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.
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.
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.
address to fetch info from
Memoized function to fetch token info
Expose ether's Provider.resolveName for ENS support
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
When started, is set to a promise which resolves when node finishes syncing
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.
The address of the token that is used to pay the services (SVT/RDN).
The address of the token that is used to pay the services (SVT/RDN).
Get current account address (subkey's address, if subkey is being used)
Instance address
Returns the Smart Contracts addresses and deployment blocks
Smart Contracts info
Instance's Logger, compatible with console's API
Logger object
Get main account address (if subkey is being used, undefined otherwise)
Main account address
Get current network from provider
Network object containing blockchain's name & chainId
Current provider getter
ether's provider instance
Fetches contract's settleTimeout
settleTimeout constant value from contracts
Gets the running state of the instance
undefined if not yet started, true if running, false if already stopped
Get current RaidenState object. Can be serialized safely with [[encodeRaidenState]]
Current Raiden state
Returns the version of the used Smart Contracts.
Smart Contract version
Returns the currently used SDK version.
SDK version
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').
Token address on currently configured token network registry
Partner address
txHash of closeChannel call, iff it succeeded
Deposit tokens on channel between us and partner on tokenNetwork for token
Token address on currently configured token network registry
Partner address
Number of tokens to deposit on channel
txHash of setTotalDeposit call, iff it succeeded
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:
The amount to deposit on behalf of the target/beneficiary.
callback providing notifications about state changes
transaction hash
Checks if a direct transfer of token to target could be performed and returns it on a single-element array of Paths
Token address on currently configured token network registry
Target address
Minimum capacity required on route
Promise to a [Raiden]Paths array containing the single, direct route, or undefined
Dumps database content for backup
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.
Promise to array of PFS, which is the interface which describes a PFS
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.
Token address on currently configured token network registry
Target address
Minimum capacity required on routes
Optional parameters
Use this PFS instead of configured or automatically choosen ones
A promise to returned routes/paths result
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$
checksummed address to be monitored
Promise to object describing availability and last event timestamp
Get ETH balance for given address or self
Optional target address. If omitted, gets own balance
BigNumber of ETH balance
Returns a promise to current block number, as seen in provider and state
Promise to current block number
Get token balance and token decimals for given address or self
Token address to fetch balance. Must be one of the monitored tokens.
Optional target address. If omitted, gets own balance
BigNumber containing address's token balance
Returns a list of all token addresses registered as token networks in registry
Whether to rescan events from scratch
Promise to list of token addresses
Get list of past and pending transfers
Filter options
filter by initiator or target address
filter by partner address
true: only pending; false: only completed; undefined: all
filter by token address
PouchDB.ChangesOptions object
Set to true to get newer transfers first
Limit number of entries
Offset to skip entries
promise to array of all transfers
Fetches balance of UserDeposit Contract for SDK's account minus cached spent IOUs
Promise to UDC remaining capacity
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.
Promise to UDC total deposit
Fetches our current UDC withdraw plan
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
Mints the amount of tokens of the provided token address. Throws an error, if
Address of the token to be minted
Amount to be minted
transaction
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
token address to monitor, must be registered in current token network registry
Address of TokenNetwork contract
Open a channel on the tokenNetwork for given token address with partner
If token isn't yet monitored, starts monitoring it
Token address on currently configured token network registry
Partner address
(optional) option parameter
Whether to wait confirmationBlocks
after last
transaction confirmation; default=true if confirmationBlocks
Deposit to perform in parallel with channel opening
Optional callback for status change notification
txHash of channelOpen call, iff it succeeded
Records a UDC withdraw plan for our UDC deposit, capped at whole balance.
Maximum value which we may try to withdraw.
Promise to hash of plan transaction, if it succeeds.
Registers and creates a new token network for the provided token address. Throws an error, if
Address of the token to be registered
The deposit limit per channel participant
The deposit limit of the whole token network
Address of new token network
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.
Token address on currently configured token network registry
Partner address
txHash of settleChannel call, iff it succeeded
Starts redux/observables by subscribing to all epics and emitting initial state and action
No event should be emitted before start is called
Triggers all epics to be unsubscribed
Fetches an ordered list of suggested partners from provided, configured or first found PFS
Token address to get partners for
Request options
PFS to use, instead of configured or automatic
Ordered array of suggested partners, with address and scoring values according to PFS
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.
Token address on currently configured token network registry
Target address
Amount to try to transfer
Optional parameters for transfer:
Whether to force encrypting the secret or not, if target supports it
Specify a lock timeout for transfer; default is expiryFactor * revealTimeout
Used to specify possible routes & fees instead of querying PFS. Should receive a decodable super-set of the public RaidenPaths interface
payment identifier, a random one will be generated if missing
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.
Secret to register, a random one will be generated if missing
Must match secret, if both provided, or else, secret must be informed to target by other means, and reveal can't be performed
A promise to transfer's unique key (id) when it's accepted
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 });
Recipient address
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
transaction 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
Token address
Recipient address
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
transaction hash
Update Raiden Config with a partial (shallow) object
Partial object containing keys and values to update in config
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
Transfer identifier as returned by transfer
Promise to final RaidenTransfer
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).
Token address on currently configured token network registry
Partner address
Amount of tokens (in wei) to withdraw, must be between 1 and ownWithdrawable
Promise to the hash of the mined withdraw transaction
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'
Maximum value which we may try to withdraw. An error will be thrown if this value is larger than getUDCCapacity+getUDCWithdrawPlan.amount
options object
if true, force withdrawing to subkey instead of the main account as beneficiary
Promise to hash of plan transaction, if it succeeds.
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
A URL or provider to connect to, one of:
An account to use as main account, one of:
diverse storage related parameters to load from and save to
PouchDB adapter; default to 'indexeddb' on browsers and 'leveldb' on node. If you provide a custom one, ensure you call PouchDB.plugin on it.
Database name prefix; use to set a directory to store leveldown db;
State uploaded by user; should be decodable by RaidenState; it is auto-migrated
Contracts deployment info, or UserDeposit contract address
Raiden configuration
Whether to use a derived subkey or not
URL of origin to generate a subkey for (defaults to global context)
Promise to Raiden SDK client instance
Generated using TypeDoc
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.