Readonly
jsonJSON-RPC responses or notifications async iterable.
Each chain contains a buffer of the responses waiting to be sent out. Iterating over this pulls one element from the buffer. If the iteration happen at a slower rate than responses are generated, then the buffer will eventually become full, at which point calling Chain.sendJsonRpc will throw an exception. The size of this buffer can be configured through AddChainOptions.jsonRpcMaxPendingRequests.
JsonRpcDisabledError If the JSON-RPC system was disabled in the options of the chain.
CrashError If the background client has crashed.
Waits for a JSON-RPC response or notification to be generated.
Each chain contains a buffer of the responses waiting to be sent out. Calling this function pulls one element from the buffer. If this function is called at a slower rate than responses are generated, then the buffer will eventually become full, at which point calling Chain.sendJsonRpc will throw an exception. The size of this buffer can be configured through AddChainOptions.jsonRpcMaxPendingRequests.
If this function is called multiple times "simultaneously" (generating multiple different
Promise
s), each Promise
will return a different JSON-RPC response or notification. In
that situation, there is no guarantee in the ordering in which the responses or notifications
are yielded. Calling this function multiple times "simultaneously" is in general a niche
corner case that you are encouraged to avoid.
AlreadyDestroyedError If the chain has been removed or the client has been terminated.
JsonRpcDisabledError If the JSON-RPC system was disabled in the options of the chain.
CrashError If the background client has crashed.
Disconnects from the blockchain.
Any on-going call to Chain.nextJsonRpcResponse is instantaneously aborted and will throw a AlreadyDestroyedError.
Trying to use the chain again after this function has returned will lead to a AlreadyDestroyedError exception being thrown.
While the chain instantaneously disappears from the public API as soon as this function is called, its shutdown process actually happens asynchronously in the background. This means for example that networking connections to the chain will remain open for a little bit even after this function returns.
If the chain is a relay chain, and that there exists Chain instances corresponding to parachains that are using this relay chain, then these parachains will continue to work and the relay chain will actually remain connected in the background. Smoldot automatically keeps alive all relay chains that have an active parachains. There is no need to track parachains and relay chains, or to destroy them in the correct order, as this is handled automatically internally.
AlreadyDestroyedError If the chain has already been removed or the client has been terminated.
CrashError If the background client has crashed.
Enqueues a JSON-RPC request that the client will process as soon as possible.
The response can be pulled by calling Chain.nextJsonRpcResponse.
See https://www.jsonrpc.org/specification for a specification of the JSON-RPC format. Only version 2 is supported. Be aware that some requests will cause notifications to be sent back through Chain.nextJsonRpcResponse.
If the request is not a valid JSON-RPC request, then a JSON-RPC error response is later
generated with an id
equal to null
, in accordance with the JSON-RPC 2.0 specification.
If, however, the request is a valid JSON-RPC request but that concerns an unknown method, or if for example some parameters are missing, an error response is properly generated and yielded through Chain.nextJsonRpcResponse.
Two JSON-RPC APIs are supported by smoldot:
JSON-encoded RPC request.
QueueFullError If the queue of JSON-RPC requests of the chain is full.
AlreadyDestroyedError If the chain has been removed or the client has been terminated.
JsonRpcDisabledError If the JSON-RPC system was disabled in the options of the chain.
CrashError If the background client has crashed.
Active connection to a blockchain.