“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
interfaceClearableToken/* is ERC-1996 */{enumClearableTransferStatusCode{Nonexistent,Ordered,InProcess,Executed,Rejected,Cancelled}functionorderTransfer(stringcalldataoperationId,addressto,uint256value)externalreturns(bool);functionorderTransferFrom(stringcalldataoperationId,addressfrom,addressto,uint256value)externalreturns(bool);functioncancelTransfer(stringcalldataoperationId)externalreturns(bool);functionprocessClearableTransfer(stringcalldataoperationId)externalreturns(bool);functionexecuteClearableTransfer(stringcalldataoperationId)externalreturns(bool);functionrejectClearableTransfer(stringcalldataoperationId,stringcalldatareason)externalreturns(bool);functionretrieveClearableTransferData(stringcalldataoperationId)externalviewreturns(addressfrom,addressto,uint256value,ClearableTransferStatusCodestatus);functionauthorizeClearableTransferOperator(addressoperator)externalreturns(bool);functionrevokeClearableTransferOperator(addressoperator)externalreturns(bool);functionisClearableTransferOperatorFor(addressoperator,addressfrom)externalviewreturns(bool);eventClearableTransferOrdered(addressindexedorderer,stringoperationId,addressindexedfrom,addressindexedto,uint256value);eventClearableTransferInProcess(addressindexedorderer,stringoperationId);eventClearableTransferExecuted(addressindexedorderer,stringoperationId);eventClearableTransferRejected(addressindexedorderer,stringoperationId,stringreason);eventClearableTransferCancelled(addressindexedorderer,stringoperationId);eventAuthorizedClearableTransferOperator(addressindexedoperator,addressindexedaccount);eventRevokedClearableTransferOperator(addressindexedoperator,addressindexedaccount);}
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.
Parameter
Description
operationId
The unique ID to identify the clearable transfer
to
The address of the payee, to whom the tokens are to be paid if executed
value
The 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.
Parameter
Description
operationId
The unique ID to identify the clearable transfer
from
The address of the payer, from whom the tokens are to be taken if executed
to
The address of the payee, to whom the tokens are to be paid if executed
value
The 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.
Parameter
Description
operationId
The 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.
Parameter
Description
operationId
The 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.
Parameter
Description
operationId
The 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.
Parameter
Description
operationId
The unique ID to identify the clearable transfer
reason
A reason given by the clearing agent why the transfer has been rejected
retrieveClearableTransferData
Retrieves all the information available for a particular clearable transfer.
Parameter
Description
operationId
The unique ID to identify the clearable transfer
authorizeClearableTransferOperator
Approves an operator to order transfers on behalf of msg.sender.
Parameter
Description
operator
The address to be approved as operator of clearable transfers
revokeClearableTransferOperator
Revokes the approval to order transfers on behalf of msg.sender.
Parameter
Description
operator
The address to be revoked as operator of clearable transfers
isClearableTransferOperatorFor
Returns if an operator is approved to order transfers on behalf of from.
Parameter
Description
operator
The address to be an operator of clearable transfers
from
The 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.
Parameter
Description
orderer
The address of the orderer of the transfer
operationId
The unique ID to identify the clearable transfer
from
The address of the payer, from whom the tokens are to be taken if executed
to
The address of the payee, to whom the tokens are to be paid if executed
value
The amount to be transferred if executed
ClearableTransferInProcess
Must be emitted when a clearable transfer is put in status ÌnProcess.
Parameter
Description
orderer
The address of the orderer of the transfer
operationId
The unique ID to identify the clearable transfer
ClearableTransferExecuted
Must be emitted when a clearable transfer is executed.
Parameter
Description
orderer
The address of the orderer of the transfer
operationId
The unique ID to identify the clearable transfer
ClearableTransferRejected
Must be emitted when a clearable transfer is rejected.
Parameter
Description
orderer
The address of the orderer of the transfer
operationId
The unique ID to identify the clearable transfer
reason
A 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.
Parameter
Description
orderer
The address of the orderer of the transfer
operationId
The unique ID to identify the clearable transfer
AuthorizedClearableTransferOperator
Emitted when an operator has been approved to order transfers on behalf of another account.
Parameter
Description
operator
The address which has been approved as operator of clearable transfers
account
Address on which behalf transfers will potentially be ordered
RevokedClearableTransferOperator
Emitted when an operator has been revoked from ordering transfers on behalf of another account.
Parameter
Description
operator
The address which has been revoked as operator of clearable transfers
account
Address 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.
Julio Faura <julio@adhara.io>, Fernando Paris <fer@io.builders>, Daniel Lehrner <daniel@io.builders>, "ERC-2018: Clearable Token [DRAFT]," Ethereum Improvement Proposals, no. 2018, April 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2018.