Client that allows connecting to chains.

Use {ScClient.addChain} or {ScClient.addWellKnownChain} to connect to a chain.

If you want to connect to a parachain, you must have connected to its corresponding relay chain with the same instance of {ScClient}. The matching between relay chains and parachains is done through the relay_chain field in the parachain specification.

interface ScClient {
    addChain: AddChain;
    addWellKnownChain: AddWellKnownChain;
}

Properties

addChain: AddChain

Connects to a chain.

Throws an exception if the chain specification isn't valid, or if the chain specification concerns a parachain but no corresponding relay chain can be found.

Substrate-connect will automatically de-duplicate chains if multiple identical chains are added, in order to save resources. In other words, it is not a problem to call addChain multiple times with the same chain specifications and obtain multiple Chain. When the same client is used for multiple different purposes, you are in fact strongly encouraged to trust substrate-connect and not attempt to de-duplicate chains yourself, as determining whether two chains are identical is complicated and might have security implications.

Substrate-connect tries to distribute CPU resources equally between all active Chain objects.

Specification of the chain to add.

Callback invoked in response to calling {Chain.sendJsonRpc}. This field is optional. If no callback is provided, the client will save up resources by not starting the JSON-RPC endpoint, and it is forbidden to call {Chain.sendJsonRpc}. Will never be called after ̀{Chain.remove} has been called or if a {CrashError} has been generated.

If the chain can't be added.

If the background client has crashed.

addWellKnownChain: AddWellKnownChain

Connects to a chain, by its id.

Throws an exception if no chain with this name is known.

Substrate-connect will automatically de-duplicate chains if multiple identical chains are added, in order to save resources. In other words, it is not a problem to call addChain multiple times with the same chain specifications and obtain multiple Chain. When the same client is used for multiple different purposes, you are in fact strongly encouraged to trust substrate-connect and not attempt to de-duplicate chains yourself, as determining whether two chains are identical is complicated and might have security implications.

Substrate-connect tries to distribute CPU resources equally between all active Chain objects.

Name of the well-known chain to add.

Same parameter as for {ScClient.addChain}

If no chain with this name is known.

If the background client has crashed.

MMNEPVFCICPMFPCPTTAAATR