主页EIPs
EIPsERC-2018
ERC-2018

Clearable Token

StagnantStandards Track: ERC
创建时间: 2019-04-30
关联 EIP: EIP-1996
Julio Faura <julio@adhara.io>, Fernando Paris <fer@io.builders>, Daniel Lehrner <daniel@io.builders>
社区讨论原文链接编辑
1 分钟了解
欢迎补充好内容
去提交
相关视频
欢迎补充好内容
去提交
正文

Simple Summary

"In banking and finance, clearing denotes all activities from the time a commitment is made for a transaction until it is settled." [1]

Actors

Clearing Agent

An account which processes, executes or rejects a clearable transfer.

Operator

An account which has been approved by an account to order clearable transfers on its behalf.

Orderer

The account which orders a clearable transfer. This can be the account owner itself, or any account, which has been approved as an operator for the account.

Abstract

The clearing process turns the promise of a transfer into the actual movement of money from one account to another. A clearing agent decides if the transfer can be executed or not. The amount which should be transferred is not deducted from the balance of the payer, but neither is it available for another transfer and therefore ensures, that the execution of the transfer will be successful when it is executed.

Motivation

A regulated token needs to comply with all the legal requirements, especially KYC and AML. Some of these checks may not be able to be done on-chain and therefore a transfer may not be completed in one step. Currently there is no EIP to make such off-chain checks possible. This proposal allows a user to order a transfer, which can be checked by a clearing agent off-chain. Depending on the result of it, the clearing agent will either execute or cancel the transfer. To provide more information why a transfer is cancelled, the clearing agent can add a reason why it is not executed.

Specification

interface ClearableToken /* is ERC-1996 */ { enum ClearableTransferStatusCode { Nonexistent, Ordered, InProcess, Executed, Rejected, Cancelled } function orderTransfer(string calldata operationId, address to, uint256 value) external returns (bool); function orderTransferFrom(string calldata operationId, address from, address to, uint256 value) external returns (bool); function cancelTransfer(string calldata operationId) external returns (bool); function processClearableTransfer(string calldata operationId) external returns (bool); function executeClearableTransfer(string calldata operationId) external returns (bool); function rejectClearableTransfer(string calldata operationId, string calldata reason) external returns (bool); function retrieveClearableTransferData(string calldata operationId) external view returns (address from, address to, uint256 value, ClearableTransferStatusCode status); function authorizeClearableTransferOperator(address operator) external returns (bool); function revokeClearableTransferOperator(address operator) external returns (bool); function isClearableTransferOperatorFor(address operator, address from) external view returns (bool); event ClearableTransferOrdered(address indexed orderer, string operationId, address indexed from, address indexed to, uint256 value); event ClearableTransferInProcess(address indexed orderer, string operationId); event ClearableTransferExecuted(address indexed orderer, string operationId); event ClearableTransferRejected(address indexed orderer, string operationId, string reason); event ClearableTransferCancelled(address indexed orderer, string operationId); event AuthorizedClearableTransferOperator(address indexed operator, address indexed account); event RevokedClearableTransferOperator(address indexed operator, address indexed account); }

Functions

orderTransfer

Orders a clearable transfer on behalf of the msg.sender in favor of to. A clearing agent is responsible to either execute or reject the transfer. The function must revert if the operation ID has been used before.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer
toThe address of the payee, to whom the tokens are to be paid if executed
valueThe amount to be transferred. Must be less or equal than the balance of the payer.

orderTransferFrom

Orders a clearable transfer on behalf of the payer in favor of the to. A clearing agent is responsible to either execute or reject the transfer. The function must revert if the operation ID has been used before.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer
fromThe address of the payer, from whom the tokens are to be taken if executed
toThe address of the payee, to whom the tokens are to be paid if executed
valueThe amount to be transferred. Must be less or equal than the balance of the payer.

cancelTransfer

Cancels the order of a clearable transfer. Only the orderer can cancel their own orders. It must not be successful as soon as the transfer is in status InProcess.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer

processClearableTransfer

Sets a clearable transfer to status InProcess. Only a clearing agent can successfully execute this action. This status is optional, but without it the orderer can cancel the transfer at any time.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer

executeClearableTransfer

Executes a clearable transfer, which means that the tokens are transferred from the payer to the payee. Only a clearing agent can successfully execute this action.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer

rejectClearableTransfer

Rejects a clearable transfer, which means that the amount that is held is available again to the payer and no transfer is done. Only a clearing agent can successfully execute this action.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer
reasonA reason given by the clearing agent why the transfer has been rejected

retrieveClearableTransferData

Retrieves all the information available for a particular clearable transfer.

ParameterDescription
operationIdThe unique ID to identify the clearable transfer

authorizeClearableTransferOperator

Approves an operator to order transfers on behalf of msg.sender.

ParameterDescription
operatorThe address to be approved as operator of clearable transfers

revokeClearableTransferOperator

Revokes the approval to order transfers on behalf of msg.sender.

ParameterDescription
operatorThe address to be revoked as operator of clearable transfers

isClearableTransferOperatorFor

Returns if an operator is approved to order transfers on behalf of from.

ParameterDescription
operatorThe address to be an operator of clearable transfers
fromThe address on which the holds would be created

transfer

It is up to the implementer of the EIP if the transfer function of ERC-20 should always revert or is allowed under certain circumstances.

transferFrom

It is up to the implementer of the EIP if the transferFrom function of ERC-20 should always revert or is allowed under certain circumstances.

Events

ClearableTransferOrdered

Must be emitted when a clearable transfer is ordered.

ParameterDescription
ordererThe address of the orderer of the transfer
operationIdThe unique ID to identify the clearable transfer
fromThe address of the payer, from whom the tokens are to be taken if executed
toThe address of the payee, to whom the tokens are to be paid if executed
valueThe amount to be transferred if executed

ClearableTransferInProcess

Must be emitted when a clearable transfer is put in status ÌnProcess.

ParameterDescription
ordererThe address of the orderer of the transfer
operationIdThe unique ID to identify the clearable transfer

ClearableTransferExecuted

Must be emitted when a clearable transfer is executed.

ParameterDescription
ordererThe address of the orderer of the transfer
operationIdThe unique ID to identify the clearable transfer

ClearableTransferRejected

Must be emitted when a clearable transfer is rejected.

ParameterDescription
ordererThe address of the orderer of the transfer
operationIdThe unique ID to identify the clearable transfer
reasonA reason given by the clearing agent why the transfer has been rejected

ClearableTransferCancelled

Must be emitted when a clearable transfer is cancelled by its orderer.

ParameterDescription
ordererThe address of the orderer of the transfer
operationIdThe unique ID to identify the clearable transfer

AuthorizedClearableTransferOperator

Emitted when an operator has been approved to order transfers on behalf of another account.

ParameterDescription
operatorThe address which has been approved as operator of clearable transfers
accountAddress on which behalf transfers will potentially be ordered

RevokedClearableTransferOperator

Emitted when an operator has been revoked from ordering transfers on behalf of another account.

ParameterDescription
operatorThe address which has been revoked as operator of clearable transfers
accountAddress on which behalf transfers could potentially be ordered

Rationale

This EIP uses EIP-1996 to hold the money after a transfer is ordered. A clearing agent, whose implementation is not part of this proposal, acts as a predefined notary to decide if the transfer complies with the rules of the token or not.

The operationId is a string and not something more gas efficient to allow easy traceability of the hold and allow human readable ids. It is up to the implementer if the string should be stored on-chain or only its hash, as it is enough to identify a hold.

The operationId is a competitive resource. It is recommended, but not required, that the hold issuers used a unique prefix to avoid collisions.

While not requiring it, the naming of the functions authorizeClearableTransferOperator, revokeClearableTransferOperator and isClearableTransferOperatorFor follows the naming convention of ERC-777.

Backwards Compatibility

This EIP is fully backwards compatible as its implementation extends the functionality of EIP-1996.

Implementation

The GitHub repository IoBuilders/clearable-token contains the reference implementation.

Contributors

This proposal has been collaboratively implemented by adhara.io and io.builders.

Copyright and related rights waived via CC0.

[1] https://en.wikipedia.org/wiki/Clearing_(finance)

扩展阅读
欢迎补充好内容
去提交
相关项目
欢迎补充好内容
去提交

不想错过最新的 EIP 动态?

订阅 EIPs Fun 周刊以跟进相关更新,建⽴你与 EIP 之间的连接 ,更好地建设以太坊。

详情
支持以太坊贡献者,推动生态建设
资源
GitHub
支持社区