How it Works

Términa Escrow provides a trustless payment infrastructure where funds are held securely until all parties agree on the outcome. Here's how the system works.

Escrow Flow

A typical escrow transaction involves three parties:

  • Issuer - Creates the invoice and receives payment
  • Payer - Accepts the invoice and deposits funds
  • Arbiter (optional) - Resolves disputes if they arise

Step 1: Invoice Creation

The issuer creates an escrow contract on the Casper blockchain with:

  • Invoice description and amount
  • Payer's wallet address
  • Optional arbiter address for disputes
  • Optional due date
// Contract deployment
const escrow = new EscrowContract({
  issuer: "0x123...",
  payer: "0x456...",
  amount: 1000_000_000_000, // 1000 CSPR in motes
  description: "Web development services"
});

Step 2: Acceptance

The payer reviews the invoice terms and accepts them. This is an on-chain transaction that records the payer's agreement to the terms.

// Payer accepts the escrow terms
await escrow.accept();
// State: DRAFT → ACCEPTED

Step 3: Funding

The payer deposits the required amount into the escrow contract. The funds are now locked and cannot be accessed by either party until released.

// Payer deposits funds
await escrow.fund({ amount: 1000_000_000_000 });
// State: ACCEPTED → FUNDED

Step 4: Release

When the payer is satisfied with the delivered goods or services, they release the funds to the issuer. This completes the escrow.

// Payer releases funds to issuer
await escrow.release();
// State: FUNDED → RELEASED
// Funds transferred to issuer

State Machine

The escrow contract implements a strict state machine with the following states:

StateDescriptionAllowed Actions
DRAFTInitial state after creationaccept, cancel
ACCEPTEDPayer agreed to termsfund, cancel
FUNDEDFunds deposited in contractrelease, dispute
RELEASEDFunds sent to issuernone (final)
CANCELLEDEscrow cancelled, funds returnednone (final)
DISPUTEDDispute raised, awaiting arbiterresolve (arbiter only)

Dispute Resolution

If there's a disagreement between issuer and payer, either party can raise a dispute when the escrow is in the FUNDED state.

Raising a Dispute

// Either party can dispute
await escrow.dispute("Deliverables not as specified");
// State: FUNDED → DISPUTED

Arbiter Resolution

The designated arbiter reviews the case and makes a decision:

  • Release to Issuer - Arbiter sides with the issuer
  • Refund to Payer - Arbiter sides with the payer
// Arbiter resolves the dispute
await escrow.resolveDispute({
  releaseToIssuer: true // or false for refund
});
// State: DISPUTED → RELEASED or CANCELLED
Note: If no arbiter is specified during escrow creation, disputes can only be resolved by mutual agreement between issuer and payer.

On-Chain Data

All escrow data is stored on the Casper blockchain:

  • Invoice metadata (ID, description, amount, dates)
  • Party addresses (issuer, payer, arbiter)
  • Current state and balance
  • Event history for full audit trail

This ensures complete transparency and immutability. All transactions can be verified on the Casper Explorer.