Smart Contracts
Job Contract
Per-job escrow contract for native TON payments. Each job is deployed as a separate contract by the JobFactory.
Source:
contracts/job.tolk — compiled with Tolk 1.2OPEN
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
| Code | State | Description |
|---|---|---|
| 0 | OPEN | Created, awaiting budget & funding |
| 1 | FUNDED | TON locked in escrow |
| 2 | SUBMITTED | Provider submitted result |
| 3 | COMPLETED | Approved — provider paid |
| 4 | DISPUTED | Rejected — client refunded |
| 5 | CANCELLED | Timeout — client refunded |
9 Operations
| Opcode | Operation | Sender | State | Effect |
|---|---|---|---|---|
| 0x01 | Fund | Client | OPEN | Lock TON → FUNDED |
| 0x02 | TakeJob | Anyone | FUNDED | Claim as provider |
| 0x03 | SubmitResult | Provider | FUNDED | Push hash → SUBMITTED |
| 0x04 | Evaluate | Evaluator | SUBMITTED | Approve/Reject |
| 0x05 | Cancel | Client | FUNDED | Refund after timeout |
| 0x06 | InitJob | Factory | Internal | Initialize data |
| 0x07 | Claim | Provider | SUBMITTED | Auto-claim 24h |
| 0x08 | Quit | Provider | FUNDED | Exit, job reopens |
| 0x09 | SetBudget | Client | OPEN | Set/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.