Interface: JobsProgram
Jobs program interface
Methods
all()
all(filters?, checkRuns?): Promise<Job[]>;Fetch all job accounts
Parameters
| Parameter | Type |
|---|---|
filters? | { market?: Address; node?: Address; project?: Address; state?: JobState; } |
filters.market? | Address |
filters.node? | Address |
filters.project? | Address |
filters.state? | JobState |
checkRuns? | boolean |
Returns
assignMany()
Call Signature
assignMany(params, count): Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>;Assign many jobs at once — the bulk counterpart to assign. Each instruction mints its own fresh job/run accounts. Call with the same params repeated count times, or with one entry per job when they differ. Returns instructions only; pass them to sendBatch.
Parameters
| Parameter | Type |
|---|---|
params | AssignParams |
count | number |
Returns
Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>
Call Signature
assignMany(params): Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>;Parameters
| Parameter | Type |
|---|---|
params | AssignParams[] |
Returns
Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>
closeMany()
closeMany(markets): Promise<CloseInstruction<Address, string, string, string, string, string, []>[]>;Close many markets at once — the bulk counterpart to close. Takes the market addresses and returns one instruction each; pass them to sendBatch.
Parameters
| Parameter | Type |
|---|---|
markets | Address[] |
Returns
Promise<CloseInstruction<Address, string, string, string, string, string, []>[]>
completeMany()
completeMany(params): Promise<CompleteInstruction<Address, string, string, []>[]>;Complete many jobs at once — the bulk counterpart to complete. Takes one params entry per job (each carries its own result hash); pass the result to sendBatch.
Parameters
| Parameter | Type |
|---|---|
params | CompleteParams[] |
Returns
Promise<CompleteInstruction<Address, string, string, []>[]>
createMarket()
createMarket(params?): Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>;Create a new market (synonym for open)
Parameters
| Parameter | Type |
|---|---|
params? | OpenParams |
Returns
Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>
delistMany()
delistMany(jobs): Promise<DelistInstruction<Address, string, string, string, string, string, string, string, []>[]>;Delist many jobs at once — the bulk counterpart to delist. Takes the job addresses and returns one instruction each; pass them to sendBatch.
Parameters
| Parameter | Type |
|---|---|
jobs | Address[] |
Returns
Promise<DelistInstruction<Address, string, string, string, string, string, string, string, []>[]>
endMany()
endMany(jobs): Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>[]>;End many running jobs at once — the bulk counterpart to end. Takes the job addresses and returns one instruction each; pass them to sendBatch.
Parameters
| Parameter | Type |
|---|---|
jobs | Address[] |
Returns
Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>[]>
extendMany()
extendMany(params): Promise<ExtendInstruction<Address, string, string, string, string, string, string, string, string, string, string, []>[]>;Extend many jobs at once — the bulk counterpart to extend. Takes one params entry per job (each carries its own timeout); pass the result to sendBatch.
Parameters
| Parameter | Type |
|---|---|
params | ExtendParams[] |
Returns
Promise<ExtendInstruction<Address, string, string, string, string, string, string, string, string, string, string, []>[]>
finishMany()
finishMany(params): Promise<FinishInstructions[]>;Finish many jobs at once — the bulk counterpart to finish. Each entry may expand to several instructions (token-account setup plus the finish), so this returns one atomic group per job; pass the result to sendBatch, which keeps each group in a single transaction.
Parameters
| Parameter | Type |
|---|---|
params | FinishParams[] |
Returns
get()
get(addr, checkRun?): Promise<Job>;Fetch a job account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
checkRun? | boolean |
Returns
listMany()
Call Signature
listMany(params, count): Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>;Build many list instructions at once — the bulk-create counterpart to list. Each instruction mints its own fresh job/run accounts. Returns instructions only; pass them to sendBatch to send them in the fewest transactions.
Call it with the same params repeated count times, or with one entry per job when the jobs differ.
Parameters
| Parameter | Type |
|---|---|
params | ListParams |
count | number |
Returns
Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>
Example
const instructions = await client.jobs.listMany({ market, ipfsHash, timeout }, 7);
const results = await client.jobs.sendBatch(instructions);Call Signature
listMany(params): Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>;Parameters
| Parameter | Type |
|---|---|
params | ListParams[] |
Returns
Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>
market()
market(addr): Promise<Market>;Fetch a market account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
Returns
markets()
markets(): Promise<Market[]>;Fetch all market accounts
Returns
monitor()
monitor(): Promise<[AsyncIterable<SimpleMonitorEvent, any, any>, () => void]>;Monitor program account updates using async iterators. Automatically merges run account data into job account updates. Returns a tuple of [eventStream, stopFunction].
Returns
Promise<[AsyncIterable<SimpleMonitorEvent, any, any>, () => void]>
Example
const [eventStream, stop] = await jobsProgram.monitor();
for await (const event of eventStream) {
if (event.type === MonitorEventType.JOB) {
console.log('Job updated:', event.data.address);
} else if (event.type === MonitorEventType.MARKET) {
console.log('Market updated:', event.data.address);
}
}monitorDetailed()
monitorDetailed(): Promise<[AsyncIterable<MonitorEvent, any, any>, () => void]>;Monitor program account updates with detailed events for each account type. Provides separate events for job, market, and run accounts. Returns a tuple of [eventStream, stopFunction].
Returns
Promise<[AsyncIterable<MonitorEvent, any, any>, () => void]>
Example
const [eventStream, stop] = await jobsProgram.monitorDetailed();
for await (const event of eventStream) {
switch (event.type) {
case MonitorEventType.JOB:
console.log('Job updated:', event.data.address);
break;
case MonitorEventType.MARKET:
console.log('Market updated:', event.data.address);
break;
case MonitorEventType.RUN:
console.log('Run updated:', event.data.address);
break;
}
}multiple()
multiple(addresses, checkRuns?): Promise<Job[]>;Fetch multiple job accounts by address
Parameters
| Parameter | Type |
|---|---|
addresses | Address[] |
checkRuns? | boolean |
Returns
open()
open(params?): Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>;Create a new market
Parameters
| Parameter | Type |
|---|---|
params? | OpenParams |
Returns
Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>
post()
post(params): Promise<
| AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>
| ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>>;Post a new job to the marketplace (can list or assign based on params)
Parameters
| Parameter | Type |
|---|---|
params | | AssignParams | ListParams |
Returns
Promise< | AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []> | ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>>
quitMany()
quitMany(runs): Promise<QuitInstruction<Address, string, string, string, string, []>[]>;Quit many runs at once — the bulk counterpart to quit. Takes the run addresses and returns one instruction each; pass them to sendBatch.
Parameters
| Parameter | Type |
|---|---|
runs | Address[] |
Returns
Promise<QuitInstruction<Address, string, string, string, string, []>[]>
run()
run(addr): Promise<Run>;Fetch a run account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
Returns
runs()
runs(filters?): Promise<Run[]>;Fetch all run accounts
Parameters
| Parameter | Type |
|---|---|
filters? | { job?: Address; node?: Address; } |
filters.job? | Address |
filters.node? | Address |
Returns
sendBatch()
sendBatch(groups, options?): Promise<JobsBatchTransactionResult[]>;Bulk-send many jobs instructions, automatically packing them into the fewest transactions that each stay within Solana's size and compute-unit limits.
Each entry of groups is a single instruction or an atomic group of instructions that must stay in the same transaction. By default each transaction's compute-unit limit is estimated by simulation, because jobs instruction cost scales with the market queue size (a static estimate would under-provision large batches). Pass estimateComputeUnits: false to use the measured static table instead (no RPC, see pnpm gen:cu). All transactions are attempted regardless of individual failures; the result reports each outcome.
Each result carries confirmed, the accounts it touched (grouped by role, e.g. accounts.jobs), the decoded instructions, and the groupIndices of the inputs it packed — so created accounts can be collected directly, or tied back to the exact input that produced them, without a bespoke *Many helper.
Parameters
| Parameter | Type | Description |
|---|---|---|
groups | ( | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[])[] | Atomic instruction groups to bulk together. |
options? | { commitment?: "processed" | "confirmed" | "finalized"; computeUnitMargin?: number; estimateComputeUnits?: boolean; feePayer?: TransactionSigner; maxComputeUnits?: number; maxTransactionSize?: number; sequential?: boolean; } | Optional configuration (fee payer, commitment, limits, simulation). |
options.commitment? | "processed" | "confirmed" | "finalized" | - |
options.computeUnitMargin? | number | - |
options.estimateComputeUnits? | boolean | - |
options.feePayer? | TransactionSigner | - |
options.maxComputeUnits? | number | - |
options.maxTransactionSize? | number | - |
options.sequential? | boolean | - |
Returns
Promise<JobsBatchTransactionResult[]>
A per-transaction result array, in the order the buckets were packed.
Examples
// Collect every created job from the confirmed transactions.
const instructions = await client.jobs.listMany({ market, ipfsHash, timeout }, 7);
const results = await client.jobs.sendBatch(instructions);
const jobs = [];
for (const tx of results) {
if (tx.confirmed) jobs.push(...tx.accounts.jobs);
}// Or tie each created job back to its input (groupIndices bridges tx -> input;
// for single-instruction inputs decoded[k] lines up with groupIndices[k]).
for (const tx of results) {
tx.groupIndices.forEach((inputIndex, k) => {
console.log(inputIndex, tx.confirmed, tx.decoded[k]?.accounts.job);
});
}signBatch()
signBatch(groups, options?): Promise<SignedJobsBatchTransaction[]>;Bulk-pack and sign jobs instructions without sending them — the build-and -sign-only counterpart to sendBatch. Returns one signed, base64 transaction per packed bucket for a separate process to persist and broadcast later (persist-before-send idempotency: a crash mid-send can replay the identical signed transaction, which the chain dedups by signature).
Each bucket is signed with all of its embedded signers (the fresh job/run keypairs minted by each list/assign plus the fee payer), and the result carries the same decoded/accounts view as sendBatch so the per-bucket job/run addresses are available without decoding raw accounts.
Compute-unit limits are set statically from the measured table (no simulation), since nothing is sent — then scaled by computeUnitMargin (default 3). The margin matters because jobs CU grows with market-queue depth (~131 CU/entry for list) and the table is a shallow measurement: a transaction signed now but broadcast later against a deeper queue could exceed a tight static limit and fail the whole bucket on landing. The protocol caps a queue at depth 250 (worst-case list ≈51,900 CU), so the default 3 (budget ≈69,000, ~depth 380) covers the entire legal range with headroom. To size it explicitly, use computeUnitMargin >= (≈19000 + 131·D_max) / 23000. Over-provisioning only costs fee — list packing is size-bound, so a larger margin does not reduce density.
Bucket atomicity applies: for operations whose instructions can already be settled (e.g. STOP/END on a finished job), a single failing instruction fails its whole bucket — pre-filter and/or use smaller buckets. LIST never hits this (every list mints fresh accounts).
Parameters
| Parameter | Type | Description |
|---|---|---|
groups | ( | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[])[] | Atomic instruction groups to bulk together. |
options? | { computeUnitMargin?: number; estimateComputeUnits?: boolean; feePayer?: TransactionSigner; maxComputeUnits?: number; maxTransactionSize?: number; } | Optional configuration (fee payer, limits). No commitment/sequential — nothing is sent. |
options.computeUnitMargin? | number | Multiplier on each instruction's static compute-unit estimate (default 3, covers the protocol's max queue depth of 250). Raise it only for deeper-than-protocol scenarios. |
options.estimateComputeUnits? | boolean | - |
options.feePayer? | TransactionSigner | - |
options.maxComputeUnits? | number | - |
options.maxTransactionSize? | number | - |
Returns
Promise<SignedJobsBatchTransaction[]>
One signed, un-sent transaction per packed bucket, in packing order.
Example
const signed = await client.jobs.signBatch(await client.jobs.listMany(params, 7));
for (const tx of signed) {
await persist({ blob: tx.blob, lastValidBlockHeight: tx.lastValidBlockHeight, jobs: tx.accounts.jobs });
// ...later, from a separate process: rpc.sendTransaction(tx.blob, { encoding: 'base64' })
}stopMany()
stopMany(markets): Promise<StopInstruction<Address, string, string, string, []>[]>;Exit the node queue for many markets at once — the bulk counterpart to stop. Takes the market addresses and returns one instruction each; pass them to sendBatch.
Parameters
| Parameter | Type |
|---|---|
markets | Address[] |
Returns
Promise<StopInstruction<Address, string, string, string, []>[]>
Properties
| Property | Type | Description |
|---|---|---|
assign | Assign | Assign a job directly to a host node |
close | Close | Close a market |
closeMarket | Close | Close a market (synonym for close) |
complete | Complete | Post the result for a JobAccount to finish it and get paid. |
delist | Delist | Delist a job from the marketplace |
end | End | Stop a running job |
extend | Extend | Extend an existing job's timeout |
finish | Finish | Complete a job that has been stopped. |
list | List | List a new job to the marketplace |
quit | Quit | Quit a JobAccount that you have started. |
stop | Stop | Exit the node queue |
work | Work | Enters the MarketAccount queue, or create a RunAccount. |