Skip to main content
EscrowManager gives you a typed API for every operation on a deployed MilestoneEscrow contract. The payer funds individual milestones, the payee marks them delivered, and the payer approves release — with optional arbiter-driven dispute resolution and a timelock auto-release safety net. It works identically against both an EVM MilestoneEscrow.sol and a Soroban milestone-escrow contract — pass the appropriate adapter.

Import


Constructor

IAdapter
required
The EVMAdapter or StellarAdapter connected to the network where the escrow is deployed. Obtain it from tokenFactory.adapter or construct one directly.
string
required
The deployed MilestoneEscrow contract address (EVM hex address or Stellar contract ID).

Read Methods

getPayer

Returns the address of the payer (the party funding the escrow).

getPayee

Returns the address of the payee (the party receiving released funds).

getArbiter

Returns the arbiter’s address. Returns the zero address if no arbiter was configured at deployment.

getToken

Returns the address of the ERC-20 / SEP-41 stablecoin held by the escrow.

getTotalAmount

Returns the sum of all milestone amounts in wei.

isFunded

Returns true if at least one milestone has been funded.

isCancelled

Returns true if both parties voted to cancel and the deal was cancelled.

milestoneCount

Returns the total number of milestones defined in the escrow.

getMilestone

Returns the full state of a single milestone.
number
required
Zero-based milestone index.
bigint
The milestone’s locked amount in wei.
string
A bytes32 hex string — the IPFS or off-chain document hash describing the deliverable.
MilestoneStatus
Current status: PENDING (0) · DELIVERED (1) · DISPUTED (2) · RELEASED (3) · REFUNDED (4)
bigint
Unix timestamp when the payee called markDelivered(). Zero if not yet delivered.
boolean
Whether the payer has funded this milestone yet.

getAllMilestones

Fetches all milestones in a single call by internally iterating from 0 to milestoneCount() - 1. Convenient for dashboard views.

remainingBalance

Returns the total amount still locked in the escrow that has not yet been released or refunded.

getActivity

Returns the full on-chain event history for this deal, sorted oldest-first.
EscrowActivityType
One of: "funded" · "delivered" · "released" · "disputed" · "resolved" · "refunded" · "cancel-vote" · "cancelled" · "arbiter-changed"
number | undefined
Present for milestone-scoped events; absent for deal-level events like "cancelled".
string
The transaction hash of the event.
number
Unix seconds. 0 if the underlying event did not carry a resolvable timestamp.

Lifecycle Write Methods

fund

Deposits the milestone’s amount into the escrow. Payer only. Milestones are funded individually — you can fund them one at a time rather than paying the full deal amount upfront. On EVM, you must approve the escrow contract to spend the required token amount before calling fund(). On Stellar, the nested token transfer is authorized within the same call.
number
required
Zero-based index of the milestone to fund.

markDelivered

Marks a funded milestone as complete. Payee only. This starts the timelock window — if the payer does not approve or dispute within the configured duration, the payee can claim via claimTimelockRelease.
number
required
Zero-based index of the milestone to mark as delivered.

approveMilestone

Approves a delivered milestone and immediately releases the funds to the payee. Payer only.
number
required
Zero-based index of the delivered milestone to approve.

raiseDispute

Freezes a delivered milestone and puts it into DISPUTED status pending arbiter review. Either the payer or the payee can raise a dispute.
number
required
Zero-based index of the milestone to dispute.
Raising a dispute requires an arbiter address to have been set at deployment time (or via setArbiter()). If the arbiter is the zero address, there is no path to resolve a disputed milestone other than a voteCancel() by both parties.

resolveDispute

Resolves a disputed milestone. Arbiter only. The arbiter decides whether funds go to the payee or are refunded to the payer.
number
required
Zero-based index of the disputed milestone.
boolean
required
Pass true to release funds to the payee, or false to refund the payer.

claimTimelockRelease

Releases funds to the payee once the timelock duration has elapsed after delivery, without requiring explicit payer approval. This protects the payee from a non-responsive payer after a successful delivery.
number
required
Zero-based index of a delivered, non-disputed milestone.

voteCancel

Casts a vote to cancel the entire deal. Both the payer and the payee must call voteCancel() — the deal is not cancelled until both votes are recorded. Any remaining funded balance is refunded to the payer on cancellation.

Admin Methods

setArbiter

Assigns or rotates the dispute arbiter. Requires MANAGER_ROLE.
string
required
Address of the new arbiter. Pass the zero address to remove arbiter access.

setIdentityVerifier

Sets or replaces the KYC identity verifier used to gate participation. Requires MANAGER_ROLE. Pass the zero address to disable KYC gating.

pause

Pauses all lifecycle transitions on the escrow. Requires admin role.

unpause

Resumes a paused escrow.

Properties


Full Lifecycle Example


Type Reference