ERC-20 token flow
Each escrow stores its own ERC-20 token address. Different escrows can therefore use different tokens.
1. Approval happens outside the escrow contract
Before funding, the client must give the escrow contract sufficient token allowance.
token.approve(escrowContractAddress, amount);2. Funding pulls tokens into escrow
fundEscrow calls:
IERC20(escrow.token).transferFrom(
msg.sender,
address(this),
escrow.amount
);If the call returns false, the escrow contract reverts with TransferFailed().
3. Approval credits internal balances
approveWork does not immediately transfer tokens. It credits:
userBalances[freelancer][token] += freelancerPayment;
userBalances[platformWallet][token] += fee;4. Withdrawal performs the transfer
A credited account calls withdraw(token, amount).
Refund path
requestRefund is different: it transfers the full escrow amount directly to the client instead of creating an internal client balance.
Token amount units
The contract treats amount as an integer in the token's base units and does not inspect token decimals.
For an 18-decimal token, one token is normally 1 × 10^18 base units. A frontend must convert human-readable values before calling the contract.