Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
This JavaScript library provides a light client for the Polkadot blockchain and for chains built using the Substrate blockchain framework.
It is an "actual" light client, in the sense that it is byzantine-resilient. It does not rely on the presence of an RPC server, but directly connects to the full nodes of the network.
import * as smoldot from 'smoldot';
// Load a string chain specification.
const chainSpec = Buffer.from(fs.readFileSync('./westend.json')).toString('utf8');
smoldot
.start({
chainSpecs: [chainSpec],
jsonRpcCallback: (jsonRpcResponse, chainIndex, connectionId) => {
// Called whenever the client emits a response to a JSON-RPC request,
// or a JSON-RPC pub-sub notification.
console.log(jsonRpcResponse)
}
})
.then((client) => {
client.sendJsonRpc('{"jsonrpc":"2.0","id":1,"method":"system_name","params":[]}', 0, 0);
})
When initializing the client with the start
function, one must pass a list of chain
specifications corresponding to the various chains the client should try to be connected to.
The start
function returns a Promise
that yield a client once the chain specifications have
been successfully parsed and basic initialization is finished, but before Internet connections
are opened towards the chains.
In order to de-initialize a client, call client.terminate()
. Any function called afterwards
will throw an exception.
After having obtained a client, use sendJsonRpc
to send a JSON-RPC request towards the node.
The function accepts three parameters:
chainSpecs
, the list of chains passed at initialization. The
request will be performed in the context of the chosen chain.userDataId
which can be used. More information below.If the request is well formatted, the client will send a response using the jsonRpcCallback
callback that was passed at initialization. This callback takes as parameter the string JSON-RPC
response, the chainIndex
, and the userDataId
. The chainIndex
and userDataId
are always
equal to the values that were passinged to sendJsonRpc
.
If the request is a subscription, the notifications will also be sent back using the same
jsonRpcCallback
.
All the pending requests and active subscriptions corresponding to a given userDataId
can be
instantly cancelled by calling client.cancelAll(userDataId)
.
The userDataId
is opaque from the point of view of smoldot, but can be used in order to match
requests with responses. Smoldot will also attempt to distribute resources allocated to processing
JSON-RPC requests equally based on the value of userDataId
.
The API described above is mostly stable. It is planned, however, in the future, to give the possibility to add and remove chains while the client is running instead of passing a list at initialization.
FAQs
Light client that connects to Polkadot and Substrate-based blockchains
The npm package smoldot receives a total of 66,331 weekly downloads. As such, smoldot popularity was classified as popular.
We found that smoldot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.