Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Simple Summary
Description of a Payable Token compatible with the ERC-20 definition.
Also description of a Token Receiver and/or Spender that accepts Payable Token payments.
Closes #1363
Abstract
The following describes standard functions a token contract and contracts working with specified token can implement to make a Token Payable.
Motivation
This proposal allows to implement an ERC-20 compatible token that can be used for payments.
It defines
transferAndCall
andtransferFromAndCall
functions that will call anonTransferReceived
on aERC1363Receiver
contract.It defines
approveAndCall
functions that will call anonApprovalReceived
on aERC1363Spender
contract.This proposal is inspired by the ERC-721
onERC721Received
andERC721TokenReceiver
behaviours.Specification
Every Payable Token compliant contract MUST implement the ERC-1363 interface other than ERC-20 and ERC-165 interfaces.
A contract that wants to accept token payments via
transferAndCall
ortransferFromAndCall
MUST implement the following interface:A contract that wants to accept token payments via
approveAndCall
MUST implement the following interface:Rationale
There are many proposed uses of Ethereum smart contracts that can accept ERC-20 payments (i.e. to create a token payable crowdsale, selling services for tokens, paying invoices, making subscriptions, use them for a specific utility and many other purposes).
This proposal wants to make token payments easier and working without the use of any other listener. It also allows to make a callback after a transfer in a single transaction.
Backwards Compatibility
This proposal is inspired also by ERC-223 and ERC-677 but it uses the ERC-721 approach so it doesn't override the ERC-20
transfer
andtransferFrom
methods and defines the interfaces IDs to be implemented maintaining the ERC-20 backwards compatibility.Test Cases
https://github.com/vittominacori/erc1363-payable-token/tree/master/test
Implementation
https://github.com/vittominacori/erc1363-payable-token/tree/master/contracts/token/ERC1363
Copyright
Copyright and related rights waived via CC0.