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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@solflare-wallet/solcast-sdk

v0.0.1

Published

Solcast is notification service built for Solana.

Downloads

3

Readme

Solcast SDK

Solcast is notification service built for Solana.

One of the main functions of Solcast is to observe Solana blockchain. Each new block and transactions in it are parsed in search of transactions linked with Public Keys Solcast is tracking.

When transaction with tracked Public Key is found events are generated for that Public Key and sent to Consumers that are interested in events from said Public Key.

Type of events are:

  • SOL balance changes
  • SPL balance changes
  • NFT balance changes

Installation

npm i @solflare-wallet/solcast-sdk

Usage of Webhook SDK

Simple usage:

const {Solcast} = require('@solflare-wallet/solcast-sdk')
const {PublicKey} = require('@solana/web3.js')


async function main() {
    const solcast = new Solcast(process.env.SOLCAST_API_KEY)
    console.log(await solcast.webhooks.all())

    try {
        const webhook = await solcast.webhooks.create("http://localhost/webhook/events", [
            new PublicKey("ABcD...0NPL"),
        ]);

        console.log(await solcast.webhooks.get(webhook.id))
        console.log(await solcast.webhooks.update(webhook.id, [
            new PublicKey("LniM...C2BB"),
        ], []))
        console.log(await solcast.webhooks.all())
        console.log(await solcast.webhooks.remove(webhook.id))
        console.log(await solcast.webhooks.all())
    } catch (error) {
        console.log(error.message)
    }
}

main()

Webhooks

Solcast Consumer accounts with Webhook API enabled can create and manage webhooks.

Each webhook has set of Public Keys that will be tracked and events about them sent to webhook's URL.

Solcast sends events in buckets of data in intervals of 5-10 seconds, if no events are available in a bucket, it will not be sent to the Webhook.

Each bucket is sent over POST HTTP request, and includes hash field which is there to prevent both replay attacks and unverified payloads. We encourage Consumers to check always validity of hash field.

|| Event bucket Hash

const secret = 'cdda0...589e0e6'

const hashString = secret + '.' + JSON.stringify(bucket.data)

const hash = crypto
    .createHash('sha256')
    .update(hashString)
    .digest('hex')

|| Example of event bucket sent to webhook

{
  "id": "ec2916a8ede53a061a46dab32a4bf58958eb54cb",
  "version": "1.0.0",
  "data": [
    {
      "signature": "inboundSolSignature",
      "tokenAddress": null,
      "nft": null,
      "token": null,
      "decimals": 9,
      "publicKey": "AC7YHa5qAm1EwLPG6Qn2reRPCzYEyUPZchQkAyRMYysf",
      "balance": "1",
      "change": "330000000",
      "type": "sol"
    },
    {
      "signature": "outboundSLRSSignature",
      "tokenAddress": "SLRSSpSLUTP7okbCUBYStWCo1vUgyt775faPqz8HUMr",
      "decimals": 6,
      "nft": null,
      "token": {
        "mint": "SLRSSpSLUTP7okbCUBYStWCo1vUgyt775faPqz8HUMr",
        "symbol": "SLRS",
        "name": "Solrise Finance",
        "logoURI": "https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/SLRSSpSLUTP7okbCUBYStWCo1vUgyt775faPqz8HUMr/logo.png"
      },
      "publicKey": "AC7YHa5qAm1EwLPG6Qn2reRPCzYEyUPZchQkAyRMYysf",
      "balance": "2000000",
      "change": "-999000",
      "type": "spl"
    }
  ],
  "hash": "4f75feb60edbad9f93b33e847b6974b8687b480c6192816c96c6722cfd91ae1f"
}

Example webhook secret: cdda02f9a8dee5826db3578fb00d7e56c72b4e4e6347d26989657a9e0b68a66c4890dd4bfd865f44b710edd118f2a3fe3915bd49c97e52acc4f02d017589e0e6