Job Escrow

The JobEscrow contract enables conditional settlement for multi-step workflows. An agent or user escrows funds, a counterparty performs the agreed service, and funds are released upon verified completion.

Contract

contract JobEscrow {
    struct Job {
        address payer;
        address payee;
        uint256 amount;
        bool completed;
    }

    mapping(uint256 => Job) public jobs;
    uint256 public nextJobId;

    /// @notice Create a new job and escrow funds.
    /// @param payee  Address of the service provider.
    /// @param amount Amount of tokens to escrow (ERC-20).
    function createJob(address payee, uint256 amount) external;

    /// @notice Mark a job as completed.
    /// Called by the payee or a Brain oracle after verification.
    function completeJob(uint256 jobId) external;

    /// @notice Release escrowed funds to the payee after completion.
    function releaseFunds(uint256 jobId) external;
}

Job Lifecycle

1

Create

Payer calls createJob, specifying the payee and amount. Funds are transferred into escrow.

2

Perform

The payee (a service provider agent or human) performs the agreed service or task.

3

Verify

Completion is verified on-chain or via a Brain oracle attesting to an off-chain result.

4

Release

releaseFunds is called after successful verification. Funds are transferred to the payee.

Use Cases

Use Case
Description

Procurement

Agent orders a service; escrowed funds release on delivery confirmation

Outsourcing

Agent delegates a sub-task to another agent with escrow protection

Service delivery

Conditional payment based on verifiable on-chain or oracle-attested outcomes

Multi-step workflows

Sequential jobs with verification gates at each stage

Integration with Brain Agents

circle-info

ERC-8183 job contracts are compatible with Brain's policy engine. Creating a job is subject to the same spend limit and allowlist checks as any other agent action.

Last updated