Escrow
In general, an escrow refers to a financial arrangement where a third party holds and regulates payment of the funds required for two parties involved in a given transaction. The funds are held by the escrow service until the process of the transaction is completed or terminated.
In the context of smart contracts, an escrow smart contract refers to a program that enforces the rules of an escrow agreement in a decentralized and automated manner. It provides a secure way to exchange assets or funds between two parties without requiring the involvement of a centralized intermediary.
The use cases for escrow smart contracts are many, but some common examples include real estate transactions, freelance work, online purchases, and crowdfunding campaigns. By using an escrow smart contract, buyers and sellers can feel more secure about the exchange, as the smart contract ensures that the agreed-upon terms are met before releasing the funds.
Example
In this example, the Escrow
contract acts as a mediator between a buyer, a seller, and an arbiter. The buyer sends the payment to the contract upon creation, and the funds are held in escrow until the arbiter determines that they should be released to the seller or refunded to the buyer.
The contract has a constructor that takes in the addresses of the buyer, seller, and arbiter, and sets the price to the amount sent to the contract. The releaseToSeller
and refundToBuyer
functions can be called by the arbiter to release the funds to the seller or refund them to the buyer, respectively.
It's worth noting that this is a very basic example, and in a real-world scenario, an escrow contract would likely have additional functionality to handle disputes and other edge cases.
Flowchart
The buyer sends ETH to the escrow smart contract.
The escrow smart contract holds the ETH in escrow.
The seller sends the goods to the buyer.
The buyer confirms receipt of the goods.
The escrow smart contract releases the ETH to the seller.
The ETH is sent to the seller.
This is a simplified example and there may be additional steps and conditions involved depending on the specifics of the transaction and the smart contract implementation.
Last updated