Skip to content

createEscrow ​

solidity
function createEscrow(
    address freelancer,
    uint256 amount,
    address token,
    uint256 durationInSeconds
) external returns (uint256)

Creates an unfunded escrow. The caller becomes the client.

Rules ​

  • freelancer cannot be zero;
  • amount must be greater than zero;
  • token cannot be zero;
  • durationInSeconds must be greater than zero.

Effects ​

The function increments nextEscrowId, calculates deadline = block.timestamp + durationInSeconds, stores the escrow with Created status, emits EscrowCreated, and returns the ID.

Reverts ​

  • ZeroAddress()
  • InvalidAmount()

Creating an escrow does not move tokens. The client must approve token spending and then call fundEscrow.

Documentation grounded in the current ERC-20 escrow implementation.