Skip to content

Interface: JobsProgram

Jobs program interface

Methods

all()

ts
all(filters?, checkRuns?): Promise<Job[]>;

Fetch all job accounts

Parameters

ParameterType
filters?{ market?: Address; node?: Address; project?: Address; state?: JobState; }
filters.market?Address
filters.node?Address
filters.project?Address
filters.state?JobState
checkRuns?boolean

Returns

Promise<Job[]>


assignMany()

Call Signature

ts
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
ParameterType
paramsAssignParams
countnumber
Returns

Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>

Call Signature

ts
assignMany(params): Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>;
Parameters
ParameterType
paramsAssignParams[]
Returns

Promise<AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>


closeMany()

ts
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

ParameterType
marketsAddress[]

Returns

Promise<CloseInstruction<Address, string, string, string, string, string, []>[]>


completeMany()

ts
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

ParameterType
paramsCompleteParams[]

Returns

Promise<CompleteInstruction<Address, string, string, []>[]>


createMarket()

ts
createMarket(params?): Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>;

Create a new market (synonym for open)

Parameters

ParameterType
params?OpenParams

Returns

Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>


delistMany()

ts
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

ParameterType
jobsAddress[]

Returns

Promise<DelistInstruction<Address, string, string, string, string, string, string, string, []>[]>


endMany()

ts
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

ParameterType
jobsAddress[]

Returns

Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>[]>


extendMany()

ts
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

ParameterType
paramsExtendParams[]

Returns

Promise<ExtendInstruction<Address, string, string, string, string, string, string, string, string, string, string, []>[]>


finishMany()

ts
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

ParameterType
paramsFinishParams[]

Returns

Promise<FinishInstructions[]>


get()

ts
get(addr, checkRun?): Promise<Job>;

Fetch a job account by address

Parameters

ParameterType
addrAddress
checkRun?boolean

Returns

Promise<Job>


listMany()

Call Signature

ts
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
ParameterType
paramsListParams
countnumber
Returns

Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>

Example
typescript
const instructions = await client.jobs.listMany({ market, ipfsHash, timeout }, 7);
const results = await client.jobs.sendBatch(instructions);

Call Signature

ts
listMany(params): Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>;
Parameters
ParameterType
paramsListParams[]
Returns

Promise<ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>[]>


market()

ts
market(addr): Promise<Market>;

Fetch a market account by address

Parameters

ParameterType
addrAddress

Returns

Promise<Market>


markets()

ts
markets(): Promise<Market[]>;

Fetch all market accounts

Returns

Promise<Market[]>


monitor()

ts
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

typescript
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()

ts
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

typescript
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()

ts
multiple(addresses, checkRuns?): Promise<Job[]>;

Fetch multiple job accounts by address

Parameters

ParameterType
addressesAddress[]
checkRuns?boolean

Returns

Promise<Job[]>


open()

ts
open(params?): Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>;

Create a new market

Parameters

ParameterType
params?OpenParams

Returns

Promise<OpenInstruction<Address, string, string, string, string, string, string, string, string, []>>


post()

ts
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

ParameterType
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()

ts
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

ParameterType
runsAddress[]

Returns

Promise<QuitInstruction<Address, string, string, string, string, []>[]>


run()

ts
run(addr): Promise<Run>;

Fetch a run account by address

Parameters

ParameterType
addrAddress

Returns

Promise<Run>


runs()

ts
runs(filters?): Promise<Run[]>;

Fetch all run accounts

Parameters

ParameterType
filters?{ job?: Address; node?: Address; }
filters.job?Address
filters.node?Address

Returns

Promise<Run[]>


sendBatch()

ts
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

ParameterTypeDescription
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

typescript
// 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);
}
typescript
// 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()

ts
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

ParameterTypeDescription
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?numberMultiplier 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

typescript
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()

ts
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

ParameterType
marketsAddress[]

Returns

Promise<StopInstruction<Address, string, string, string, []>[]>

Properties

PropertyTypeDescription
assignAssignAssign a job directly to a host node
closeCloseClose a market
closeMarketCloseClose a market (synonym for close)
completeCompletePost the result for a JobAccount to finish it and get paid.
delistDelistDelist a job from the marketplace
endEndStop a running job
extendExtendExtend an existing job's timeout
finishFinishComplete a job that has been stopped.
listListList a new job to the marketplace
quitQuitQuit a JobAccount that you have started.
stopStopExit the node queue
workWorkEnters the MarketAccount queue, or create a RunAccount.