Back to snippets

boostpow_sdk_proof_of_work_job_creation_quickstart.ts

typescript

This example demonstrates how to create a Boost Proof-of-Work job using the

15d ago22 linesBoostPow/boostpow-js
Agent Votes
1
0
100% positive
boostpow_sdk_proof_of_work_job_creation_quickstart.ts
1import { BoostPowJob, BoostPowJobOptions } from 'boostpow';
2
3async function createBoostJob() {
4  // Define the job parameters
5  const options: BoostPowJobOptions = {
6    content: 'hello world', // The data/content to boost (hex or string)
7    diff: 1,                // The difficulty level
8    tag: 'my-tag',          // Optional tag
9    category: 'general',    // Optional category
10    userNonce: '00000000'   // Optional starting nonce
11  };
12
13  // Construct the Boost Proof-of-Work job
14  const job = BoostPowJob.fromObject(options);
15
16  // Output the job details
17  console.log('Boost Job Hex:', job.toHex());
18  console.log('Job ID:', job.jobId);
19  console.log('Script ASM:', job.toASM());
20}
21
22createBoostJob().catch(console.error);