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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@snowflake-so/snowflake-sdk

v1.0.12

Published

Typescript SDK for Snowflake automation protocol

Downloads

8

Readme

Snowflake TypeScript SDK

Snowflake SDK provides services and a set of APIs used for interacting with the automation infrastructure of Snowflake on Solana blockchain. Learn more about Snowflake here.

Installation

Install with npm

npm i @snowflake-so/snowflake-sdk

Install with yarn

yarn add @snowflake-so/snowflake-sdk

Quick start guide

Initialize Snowflake

To create a new Snowflake service, we would need to initialize with the Provider.

// if your Anchor version is older than 0.24.2, 
// please use Snowflake SDK version 1.0.11 and initialize the provider as below
let provider: Provider = Provider.local(API_URL);

// if your Anchor version is 0.24.2 or later, 
// please use the latest version of Snowflake SDK and initialize the provider as below
let provider: Provider = AnchorProvider.local(API_URL); 

The API_URL is the endpoint to the Solana cluster. Empty API_URL is pointed to the local testnet

  • Mainnet Beta: https://api.mainnet-beta.solana.com
  • Testnet: https://api.testnet.solana.com
  • Devnet: https://api.devnet.solana.com
let snowflake: Snowflake = new Snowflake(provider);

Build an once-off scheduled job

With Snowflake SDK, you can create a job with two line of code.

const job = new JobBuilder()
  .jobName("hello world")
  .jobInstructions(instructions)
  .scheduleOnce(tomorrow())
  .build();

await snowflake.createJob(job);

Build a recurring scheduled job

Schedule a job that runs every minute for 10 times.

const job = new JobBuilder()
  .jobName("hello world")
  .jobInstructions(instructions)
  .scheduleCron("* * * * *", 10)
  .build();

await snowflake.createJob(job);

Schedule a job that runs at 10:00 AM on the first day of every month .

const job = new JobBuilder()
  .jobName("hello world")
  .jobInstructions(instructions)
  .scheduleCron("0 10 1 * *")
  .build();

await snowflake.createJob(job);

Build a program condition triggered job

Schedule a job that is triggered based on an arbitrary condition defined within the user program.

const job = new JobBuilder()
  .jobName("hello world")
  .jobInstructions(instructions)
  .scheduleConditional(1)
  .build();

await snowflake.createJob(job);

Build a self-funded job

Self-funded job will take an account to pay fees on its own by using the initial fund. Fee account is no longer used for paying the job's fee.

const job = new JobBuilder()
  .jobName("hello world")
  .jobInstruction(instructions)
  .scheduleConditional(1);
  .selfFunded(true)
  .initialFund(100000) // 1000000 lamports
  .build()

await snowflake.createJob(job)

Update a job

await snowflake.updateJob(jobPubkey);

Delete a job

await snowflake.deleteJob(jobPubkey);

Fetch Job by public key

await snowflake.fetch(jobPubkey);

Fetch Job by owner

await snowflake.fetchByOwner(owner);

Get Snowflake PDA

await snowflake.getSnowflakePDAForUser(userPublicKey);

Deposit fee account

await snowflake.depositFeeAccount(lamports);

Usage

import { JobBuilder, Snowflake } from "@snowflake-so/snowflake-sdk";
import { Provider } from "@project-serum/anchor";

/** Initialize a Snowflake service on Devnet **/
const API_URL: string = "https://api.devnet.solana.com";
const provider: Provider = new Provider(API_URL);
const snowflake: Snowflake = new Snowflake();

async function main() {
  /** Create a sample instruction **/
  const instructions = [
    {
      programId: new PublicKey("ETwBdF9X2eABzmKmpT3ZFYyUtmve7UWWgzbERAyd4gAC"),
      data: Buffer.from("74b89fceb3e0b22a", "hex"),
      keys: [
        {
          pubkey: new PublicKey("5jo4Lh2Z9FGQ87sDhUBwZjNZdL15MwdeT5WUXKfwFSZY"),
          isSigner: false,
          isWritable: false,
        },
      ],
    },
  ];

  /** Create a new once-off scheduled job **/
  const onceOffJob = new JobBuilder()
    .jobName("once-off job")
    .jobInstructions(instructions)
    .scheduleOnce(1646034062)
    // Timestamp: Monday, 28-Feb-22 07:41:02 UTC
    .build();

  const onceOffJobTxID = await snowflake.createJob(onceOffJob);
  console.log("Create a recurring job with txId: " + onceOffJobTxID);

  /** Create a new recurring scheduled job **/
  const recurringJob = new JobBuilder()
    .jobName("recurring job")
    .jobInstruction(instructions)
    .scheduleCron("* * * * *")
    // Every minute
    .build();

  const recurringJobTxID = await snowflake.createJob(recurringJob);
  console.log("Create a recurring job with txId: " + recurringJobTxID);

  /** Fetch an once-off job **/
  const fetchedOnceOffJob = await snowflake.fetch(onceOffJob.pubkey);

  // Build from an existing job
  const updatedJob = new JobBuilder()
    .fromExistingJob(fetchedOnceOffJob)
    .jobName("hello world 2")
    .scheduleCron("0 * * * *", 2)
    .build();

  /** Update a job **/
  await snowflake.updateJob(updatedJob);

  /** Delete a job **/
  await snowflake.deleteJob(job.pubKey);

  /** Get Snowflake PDA for user **/
  const walletAddress: PublicKey = provider.wallet.publicKey;
  await snowflake.getSnowflakePDAforUser(walletAddress);

  /** Deposit to fee account (5000000 lamports) **/
  await snowflake.depositFeeAccount(5000000);
}

Support

Struggle with the SDK integration?

If you have any problem with using the SDK in your system, drop a question our Snowflake Discord #sdk to receive a support from our engineers.

Find a bug? Find a new idea for Snowflake?

If you find a bug or have any problem and idea while using the SDK, you can create an issue on Snowflake SDK Github.

License

MIT