This article covers some most basics uses of the Snowflake SDK
Build a once-off scheduled job
With Snowflake SDK, you can create a job with two lines 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 for paying 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(job);
Delete a job
await snowflake.deleteJob(jobPubkey);
Fetch Job by public key
await snowflake.fetch(jobPubkey);
Fetch Job by owner
await snowflake.fetchByOwner(owner);