{"id":13455505,"url":"https://github.com/snowflake-so/snowflake-sdk","last_synced_at":"2025-04-14T15:13:44.323Z","repository":{"id":38191785,"uuid":"465565250","full_name":"snowflake-so/snowflake-sdk","owner":"snowflake-so","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-09T15:04:29.000Z","size":137,"stargazers_count":38,"open_issues_count":4,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T15:13:36.856Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snowflake-so.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-03T04:18:32.000Z","updated_at":"2025-01-03T18:41:51.000Z","dependencies_parsed_at":"2022-08-18T17:52:34.900Z","dependency_job_id":null,"html_url":"https://github.com/snowflake-so/snowflake-sdk","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflake-so%2Fsnowflake-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflake-so%2Fsnowflake-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflake-so%2Fsnowflake-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflake-so%2Fsnowflake-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snowflake-so","download_url":"https://codeload.github.com/snowflake-so/snowflake-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248904637,"owners_count":21180835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:01:06.369Z","updated_at":"2025-04-14T15:13:44.302Z","avatar_url":"https://github.com/snowflake-so.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Snowflake TypeScript SDK\n\nSnowflake SDK provides services and a set of APIs used for interacting with the automation infrastructure of Snowflake on Solana blockchain. Learn more about Snowflake \u003ca href=\"https://docs.snowflake.so/en/\"\u003ehere\u003c/a\u003e.\n\n## Installation\n\nInstall with npm\n\n```bash\nnpm i @snowflake-so/snowflake-sdk\n```\n\nInstall with yarn\n\n```bash\nyarn add @snowflake-so/snowflake-sdk\n```\n\n## Quick start guide\n\n### Initialize Snowflake\n\nTo create a new Snowflake service, we would need to initialize with the Provider.\n\n\n```typescript\n// if your Anchor version is older than 0.24.2, \n// please use Snowflake SDK version 1.0.11 and initialize the provider as below\nlet provider: Provider = Provider.local(API_URL);\n\n// if your Anchor version is 0.24.2 or later, \n// please use the latest version of Snowflake SDK and initialize the provider as below\nlet provider: Provider = AnchorProvider.local(API_URL); \n```\n\nThe `API_URL` is the endpoint to the Solana cluster. Empty API_URL is pointed to the `local testnet`\n\n- Mainnet Beta: `https://api.mainnet-beta.solana.com`\n- Testnet: `https://api.testnet.solana.com`\n- Devnet: `https://api.devnet.solana.com`\n\n```typescript\nlet snowflake: Snowflake = new Snowflake(provider);\n```\n\n### Build an once-off scheduled job\n\nWith Snowflake SDK, you can create a job with two line of code.\n\n```typescript\nconst job = new JobBuilder()\n  .jobName(\"hello world\")\n  .jobInstructions(instructions)\n  .scheduleOnce(tomorrow())\n  .build();\n\nawait snowflake.createJob(job);\n```\n\n### Build a recurring scheduled job\n\nSchedule a job that runs every minute for 10 times.\n\n```typescript\nconst job = new JobBuilder()\n  .jobName(\"hello world\")\n  .jobInstructions(instructions)\n  .scheduleCron(\"* * * * *\", 10)\n  .build();\n\nawait snowflake.createJob(job);\n```\n\nSchedule a job that runs at 10:00 AM on the first day of every month .\n\n```typescript\nconst job = new JobBuilder()\n  .jobName(\"hello world\")\n  .jobInstructions(instructions)\n  .scheduleCron(\"0 10 1 * *\")\n  .build();\n\nawait snowflake.createJob(job);\n```\n\n### Build a program condition triggered job\n\nSchedule a job that is triggered based on an arbitrary condition defined within the user program.\n\n```typescript\nconst job = new JobBuilder()\n  .jobName(\"hello world\")\n  .jobInstructions(instructions)\n  .scheduleConditional(1)\n  .build();\n\nawait snowflake.createJob(job);\n```\n\n### Build a self-funded job\n\nSelf-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.\n\n```typescript\nconst job = new JobBuilder()\n  .jobName(\"hello world\")\n  .jobInstruction(instructions)\n  .scheduleConditional(1);\n  .selfFunded(true)\n  .initialFund(100000) // 1000000 lamports\n  .build()\n\nawait snowflake.createJob(job)\n```\n\n### Update a job\n\n```typescript\nawait snowflake.updateJob(jobPubkey);\n```\n\n### Delete a job\n\n```typescript\nawait snowflake.deleteJob(jobPubkey);\n```\n\n### Fetch Job by public key\n\n```typescript\nawait snowflake.fetch(jobPubkey);\n```\n\n### Fetch Job by owner\n\n```typescript\nawait snowflake.fetchByOwner(owner);\n```\n\n### Get Snowflake PDA\n\n```typescript\nawait snowflake.getSnowflakePDAForUser(userPublicKey);\n```\n\n### Deposit fee account\n\n```typescript\nawait snowflake.depositFeeAccount(lamports);\n```\n\n## Usage\n\n```typescript\nimport { JobBuilder, Snowflake } from \"@snowflake-so/snowflake-sdk\";\nimport { Provider } from \"@project-serum/anchor\";\n\n/** Initialize a Snowflake service on Devnet **/\nconst API_URL: string = \"https://api.devnet.solana.com\";\nconst provider: Provider = new Provider(API_URL);\nconst snowflake: Snowflake = new Snowflake();\n\nasync function main() {\n  /** Create a sample instruction **/\n  const instructions = [\n    {\n      programId: new PublicKey(\"ETwBdF9X2eABzmKmpT3ZFYyUtmve7UWWgzbERAyd4gAC\"),\n      data: Buffer.from(\"74b89fceb3e0b22a\", \"hex\"),\n      keys: [\n        {\n          pubkey: new PublicKey(\"5jo4Lh2Z9FGQ87sDhUBwZjNZdL15MwdeT5WUXKfwFSZY\"),\n          isSigner: false,\n          isWritable: false,\n        },\n      ],\n    },\n  ];\n\n  /** Create a new once-off scheduled job **/\n  const onceOffJob = new JobBuilder()\n    .jobName(\"once-off job\")\n    .jobInstructions(instructions)\n    .scheduleOnce(1646034062)\n    // Timestamp: Monday, 28-Feb-22 07:41:02 UTC\n    .build();\n\n  const onceOffJobTxID = await snowflake.createJob(onceOffJob);\n  console.log(\"Create a recurring job with txId: \" + onceOffJobTxID);\n\n  /** Create a new recurring scheduled job **/\n  const recurringJob = new JobBuilder()\n    .jobName(\"recurring job\")\n    .jobInstruction(instructions)\n    .scheduleCron(\"* * * * *\")\n    // Every minute\n    .build();\n\n  const recurringJobTxID = await snowflake.createJob(recurringJob);\n  console.log(\"Create a recurring job with txId: \" + recurringJobTxID);\n\n  /** Fetch an once-off job **/\n  const fetchedOnceOffJob = await snowflake.fetch(onceOffJob.pubkey);\n\n  // Build from an existing job\n  const updatedJob = new JobBuilder()\n    .fromExistingJob(fetchedOnceOffJob)\n    .jobName(\"hello world 2\")\n    .scheduleCron(\"0 * * * *\", 2)\n    .build();\n\n  /** Update a job **/\n  await snowflake.updateJob(updatedJob);\n\n  /** Delete a job **/\n  await snowflake.deleteJob(job.pubKey);\n\n  /** Get Snowflake PDA for user **/\n  const walletAddress: PublicKey = provider.wallet.publicKey;\n  await snowflake.getSnowflakePDAforUser(walletAddress);\n\n  /** Deposit to fee account (5000000 lamports) **/\n  await snowflake.depositFeeAccount(5000000);\n}\n```\n\n## Support\n\n**Struggle with the SDK integration?**\n\nIf 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.\n\n**Find a bug? Find a new idea for Snowflake?**\n\nIf you find a bug or have any problem and idea while using the SDK, you can create an issue on Snowflake SDK Github.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowflake-so%2Fsnowflake-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnowflake-so%2Fsnowflake-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowflake-so%2Fsnowflake-sdk/lists"}