npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

solana-rpc

v2.6.3

Published

Solana network wrapper to interact with accounts and programs

Readme

solana-rpc

Solana network wrapper to interact with accounts and programs

npm i solana-rpc

Need support? Join the community: https://lucasbarrena.com

Usage

const RPC = require('solana-rpc')

const rpc = new RPC()

const result = await rpc.request('getSlot', [{ commitment: 'processed' }])
// => 325801337

const slot = await rpc.getSlot()
// => 325801337

const block = await rpc.getBlock(slot)
// => { parentSlot, blockTime, blockhash, previousBlockhash, ... }

const exampleTx = block.transactions[0]
const tx = await rpc.getTransaction(exampleTx.transaction.signatures[0])
// => { meta, transaction, ... }

HTTP-based real-time efficient stream of blocks!

const start = await rpc.getSlot()
const readStream = rpc.createBlockStream({ start, live: true })

for await (const block of readStream) {
  console.log('Block', block.parentSlot + 1, 'Txs', block.transactions.length)
}

WebSocket example:

await rpc.connect()

const subscription = await rpc.send('slotSubscribe')

rpc.socket.on('message', function (msg) {
  console.log(msg)
})

await rpc.send('slotUnsubscribe', [subscription])

await rpc.disconnect()

API

rpc = new RPC([options])

Creates a new Solana instance to interact with the network.

{
  url: 'https://solana-rpc.publicnode.com',
  ws: 'wss://solana-rpc.publicnode.com',
  commitment: 'processed' // 'confirmed' or 'finalized'
}

There is api.mainnet-beta.solana.com but it's more rate-limited.

HTTP API

result = await rpc.request(method[, params])

Send a custom request with parameters.

It automatically retries in case of failures.

slot = await rpc.getSlot([options])

Get the current slot.

Options:

{
  commitment
}

block = await rpc.getBlock(blockNumber)

Get a specific block.

Options:

{
  encoding: 'json',
  commitment, // 'confirmed' or 'finalized'
  transactionDetails: 'full'
}

blocks = await rpc.getBlocks(start, end[, options])

Get a range of blocks. Same options as getBlock.

end is exclusive.

tx = await rpc.getTransaction(signature[, options])

Get a full transaction by hash.

Options:

{
  encoding: 'json'
}

signatures = await rpc.getSignaturesForAddress(address[, options])

Get a list of signatures by account address.

Options:

{
  commitment, // 'confirmed' or 'finalized'
  minContextSlot,
  limit: 1000,
  before, // I.e. a signature
  until
}

readStream = rpc.createBlockStream(options)

Get a range of blocks by a HTTP-based stream efficiently.

Options:

{
  start: 0, // Must set a slot
  end: -1,
  snapshot: true, // Reads until current slot
  live: false,
  prefetch: 30
}

Example of live reading without stopping:

const slot = await rpc.getSlot()

const liveStream = rpc.createBlockStream({
  start: slot,
  live: true
})

for await (const block of liveStream) {
  if (block === Symbol.for('solana-block-missing')) {
    continue
  }

  // ...
}

WebSocket API

await rpc.connect()

Open the WebSocket.

await rpc.disconnect()

Close the WebSocket.

result = await rpc.send(method, params[, options])

Similar to rpc.request but uses the WebSocket.

Options:

{
  wait: true // Waits for the confirmation message
}

Disabling wait makes it return { id } instead of the result.

rpc.socket.on('open', callback)

Event for when the socket is connected.

rpc.socket.on('close', callback)

Event for when the socket is disconnected for any reason.

Use this event to manually reconnect with await rpc.connect().

You will have to re-subscribe.

rpc.socket.on('message', callback)

Listen for new messages in real-time.

rpc.socket.on('error', callback)

Event for errors in the socket.

await rpc.waitForMessage(callback)

Wait for a specific message.

Example:

const req = await rpc.send('slotSubscribe', { wait: false })
const result = await rpc.waitForMessage(msg => msg.id === req.id)

License

MIT