Skip to content

Frontend integration ​

A useful frontend should mirror the state machine rather than show every action at once.

Client flow ​

  1. Call createEscrow.
  2. Approve the selected ERC-20 token to the escrow contract.
  3. Call fundEscrow.
  4. Wait for WorkDelivered or read the escrow state.
  5. Call approveWork.

It is of utmost importance that the interface separates token approval from escrow funding. They are distinct transactions.

Freelancer flow ​

  1. Discover escrows assigned to the connected wallet.
  2. Wait until the escrow is Funded.
  3. Call deliverWork.
  4. Wait for client approval.
  5. Read getUserBalance(freelancer, token).
  6. Call withdraw.

Status-aware actions ​

StatusClientFreelancer
CreatedApprove token + fundWait
Funded before deadlineWaitDeliver
Funded after deadlineRefund or waitDeliver
DeliveredApproveWait
Approved—Withdraw credited balance
Refunded——

Token decimals ​

The contract expects base units. A frontend must convert human-readable values using the token's decimals before sending transactions.

Error handling ​

Handle custom errors, wallet rejection, insufficient token balance, insufficient allowance, network mismatch, and token-originated reverts separately. Do not collapse all failures into “Transaction failed.”

Documentation grounded in the current ERC-20 escrow implementation.