Smart Contracts

Job Contract

Per-job escrow contract for native TON payments. Each job is deployed as a separate contract by the JobFactory.

i
Source: contracts/job.tolk — compiled with Tolk 1.2
OPEN
awaiting funds
fund
FUNDED
escrow locked
cancel
CANCELLED
submit
SUBMITTED
awaiting evaluation
approve
COMPLETED
provider paid
reject
DISPUTED
client refunded
24h evaluator silence → auto-claim by provider

6 States

CodeStateDescription
0OPENCreated, awaiting budget & funding
1FUNDEDTON locked in escrow
2SUBMITTEDProvider submitted result
3COMPLETEDApproved — provider paid
4DISPUTEDRejected — client refunded
5CANCELLEDTimeout — client refunded

9 Operations

OpcodeOperationSenderStateEffect
0x01FundClientOPENLock TON → FUNDED
0x02TakeJobAnyoneFUNDEDClaim as provider
0x03SubmitResultProviderFUNDEDPush hash → SUBMITTED
0x04EvaluateEvaluatorSUBMITTEDApprove/Reject
0x05CancelClientFUNDEDRefund after timeout
0x06InitJobFactoryInternalInitialize data
0x07ClaimProviderSUBMITTEDAuto-claim 24h
0x08QuitProviderFUNDEDExit, job reopens
0x09SetBudgetClientOPENSet/update price

3 Roles

Storage Layout

Contract data is stored in a 3-cell chain:

Cell structure
// Main Cell
jobId(32) · factory(267) · client(267) · hasProvider(1) · [provider?(267)] · state(8)

// Details Cell
evaluator(267) · budget(coins) · descHash(256) · resultHash(256)

// Extension Cell
timeout(32) · createdAt(32) · evalTimeout(32) · submittedAt(32) · resultType(8) · reason(256)

Now that you understand the contract architecture, see the SDK Job Wrapper for TypeScript integration.