Escrow

Summary

Before making a transaction, tokens are transferred to a third-party smart contract called the escrow. The escrow holds the deposited tokens until the payment conditions are satisfied.

Context

The parties involved in the transaction need to ensure that both the agreed product/service is delivered and payment is made. One party should not be able to default the transaction at the expense of the other party.

Problem

How to ensure that the buyer gets the desired product/service while ensuring the seller gets the payment?

Forces

  • Trust – It is hard for the parties involved in a transaction to completely trust a third party with their private information and funds.
  • Efficiency – It is time-consuming to establish a trust account and regulate the funds in a centralised payment system.
  • Cost – Centralised payment systems often charge high fees for trust account services.
  • Security – When the funds are controlled from a single point, there is a possibility of funds could be stolen or mistakes are made.
  • Volume – Buyers and sellers may be engaged in a large number of transactions.

Solution

As seen in the figure below, a smart contract can play the role of an escrow that holds the fund until the payment conditions are fulfilled. First, specify the settlement procedure and conditions as a smart contract. This smart contract could be specified and deployed by either the seller or buyer. Second, the buyer transfers the token(s)to the escrow smart contract. Third, when token release conditions are met by providing the desired product/server, the respective event is informed to the escrow smart contract. Finally, the escrow validates the pre-defined conditions and releases the tokens to the seller. If the respective event is not informed to the escrow within the stipulated time or the event indicates that the product/service was not delivered as per the agreed terms, then the tokens are sent back to the buyer.

Sequence diagram of escrow

Sequence diagram of escrow

If the payment conditions depend only on on-chain data, then delegated call can be made to the escrow contract to inform the delivery of the product/service. If the payment conditions depend on external data like the shipment of a product, the oracle pattern can be used to provide desired data to the escrow. The security of escrow functionality implemented by the smart contract can be ensured as the smart contract code is immutable once deployed on the blockchain. This gives the parties involved in the transaction confidence that they will not be cheated during the trade. Care must be taken to ensure that the specified settlement conditions are unambiguous. For example, if the delivery is to be performed within 7-days, the smart contract should also specify from when the clock should start and whether it is sufficient for the seller to ship the product or whether it needs to be received by the buyer by the deadline. Further, it is recommended to specify the time in terms of a block number, as the block timestamp is not precise or could be crafted by a miner within a specific window.

Benefits

  • Trust and security – An escrow smart contract reduces the risk of fraud by acting as a neutral party and ensuring proper escrow logic execution.
  • Transparency – Operations happening in the system are trans-parent as relevant transactions are accessible to all blockchain participants.
  • Efficiency – Blockchain eliminates the need for third parties, which in turn helps to reduce the transaction cost and enhances service efficiency.

Drawbacks

  • Cost – Transaction fees need to be paid to deploy and execute the escrow smart contract on public blockchains.
  • Privacy – As all blockchain transactions are transparent, escrow transactions can potentially leak sensitive business information, e.g., the rate of disputes with customers.

Related patterns

  • Tokens can be transferred to/from the token contract generated using the token template pattern.
  • If the token registry pattern is used, seller’s and buyer’s balances need to be updated on the registry.
  • The oracle pattern can be used to provide the data required to validate physical product or service delivery.
  • Alternatively, the buyer and seller may sign a transaction using the multiple authorisation pattern to inform the escrow about the successful delivery of the product or service.
  • The stealth address pattern can be used to generate one-time addresses to transact with the escrow to enhance privacy.

Known uses 

  • Kleros Escrow is a blockchain-based trustless dispute resolution platform that provides escrow services for cross-chain asset swaps.
  • Counos is a blockchain platform based in Switzerland, which offers financial and payment services, including multisignature-based escrow for cryptocurrencies.
  • IBC Group is a blockchain financial services company that offers smart-contract-based cryptocurrency escrow services charging 1% fee in fiat currency.
  • Merchant Token brings consumer protection concept from the traditional card payment industry to blockchains by locking away a buyer’s payment to a seller with less reputation until delivery of the product/service is confirmed, or disputes are resolved.