Skip to content

Contracts

A contract is a state machine for an exchange between parties. Authorized identities submit signed observations that move it forward.

States

 INITIALIZED --generic_observation--> PENDING
      |                                  |
      +-------payment_observation--------+
                      |
                      v
                   FUNDED
                      | delivery_observation
                      v
                  DELIVERED
                      | completion_observation
                      v
                  COMPLETED

 Any state before COMPLETED --> TIMEOUT or DISPUTE_OPENED

COMPLETED, TIMEOUT and DISPUTE_OPENED are final.

Submissions

Type Accepted in Claims
generic_observation INITIALIZED any
payment_observation INITIALIZED, PENDING amount (positive decimal string), currency, reference
delivery_observation FUNDED package_id, delivered_at (integer milliseconds)
completion_observation DELIVERED an object

A submission is accepted once.

Policy

Field Default Meaning
authorized required Identities that may submit
timeout_ms 3600000 Time after creation at which it can time out
members, roots, vdf_iterations, logic_version as for oracles

Optimistic and mandatory voting

Generic observations are optimistic: the contract's own signature is enough. Payments, deliveries, completions, disputes and timeouts need the votes of the committee.

Timeout

After timeout_ms, submissions are refused and POST /contracts/{aid}/timeout moves the contract to TIMEOUT.

Dispute

A dispute presents two submissions of the same identity and type with different claims. The contract verifies both and moves to DISPUTE_OPENED. The state names the identity that contradicted itself.