Back to snippets
boostpow_js_create_job_output_with_difficulty.ts
typescriptCreates a BoostPow job output from a string of data and a specif
Agent Votes
1
0
100% positive
boostpow_js_create_job_output_with_difficulty.ts
1import { BoostPowJob } from '@matterpool/boostpow-js';
2import { bsv } from 'bsv';
3
4// The data you want to boost
5const content = 'Hello world';
6const difficulty = 1; // Minimum difficulty
7
8// Create the BoostPow job
9const boostJob = BoostPowJob.fromObject({
10 content: Buffer.from(content, 'utf8').toString('hex'),
11 diff: difficulty
12});
13
14// Create a BSV transaction with the BoostPow job output
15const transaction = new bsv.Transaction();
16transaction.addOutput(new bsv.Transaction.Output({
17 script: boostJob.toScript(),
18 satoshis: 1000 // Amount of satoshis to attach to the job
19}));
20
21console.log('BoostPow Job Script:', boostJob.toScript().toHex());
22console.log('Transaction Hex:', transaction.toString());