This standard is an extension of EIP-20. This specification defines a type of escrow service with the following flow:
Because of the pseudonymous nature of cryptocurrencies, there is no automatic recourse to recover funds that have already been paid.
In traditional finance, trusted escrow services solve this problem. In the world of decentralized cryptocurrency, however, it is possible to implement an escrow service without a third-party arbitrator. This standard defines an interface for smart contracts to act as an escrow service with a function where tokens are sent back to the original wallet if the escrow is not completed.
There are two types of contract for the escrow process:
constructorThe Escrow Contract demonstrates details of escrow policies as none-mutable matter in constructor implementation.
The Escrow Contract MUST define the following policies:
The Escrow Contract MAY define the following policies:
escrowFundFunds _value amount of tokens to address _to.
In the case of Escrow Contract:
_to MUST be the user address.msg.sender MUST be the Payable Contract address.In the case of Payable Contract:
_to MUST be the Escrow Contract address._to MUST be msg.sender to recognize the user address in the Escrow Contract.escrowRefundRefunds _value amount of tokens from address _from.
In the case of Escrow Contract:
_from MUST be the user address.msg.sender MUST be the Payable Contract address.In the case of Payable Contract:
_from MUST be the Escrow Contract address._from MUST be msg.sender to recognize the user address in the Escrow Contract.escrowWithdrawWithdraws funds from the escrow account.
In the case of Escrow Contract:
msg.sender's seller and buyer contract wallets.In the case of Payable Contract, it is optional.
This example demonstrates simple exchange of one seller and one buyer in one-to-one exchange rates.
The interfaces cover the escrow operation's refundable issue.
The suggested 3 functions (escrowFund, escrowRefund and escrowWithdraw) are based on transfer function in EIP-20.
escrowFund send tokens to the Escrow Contract. The Escrow Contract can hold the contract in the escrow process or reject tokens if the policy does not meet.
escrowRefund can be invoked in the middle of the escrow process or when the escrow process fails.
escrowWithdraw allows users (sellers and buyers) to transfer tokens from the escrow account. When the escrow process completes, the seller can get the buyer's token, and the buyers can get the seller's token.
The Payable Contract which implements this EIP is fully backward compatible with the EIP-20 specification.
This test case demonstrates the following conditions for exchanging seller/buyer tokens.
Since the Escrow Contract controls seller and buyer rights, flaws within the Escrow Contract will directly lead to unexpected behavior and potential loss of funds.
Copyright and related rights waived via CC0.