1

First of all, this question was asked before here: Accepting ERC-20 Tokens as payment but I want to see if a better way has been developed to accept ERC-20 for payment, so I'm asking again. To summarize the previous post, you change the payment slightly to make it unique. If I am forced to implement it this way, I would probably keep an incrementing variable "order id", and for each sale, increment the variable and add that amount of wei to the token amount. Then to match a sale to a payment, I just find the transaction with the last n significant digits that match that order id.

This is undesirable because 1. it messes with bookkeeping and 2. it's a kludge. There has to be a better way.

The other possibility I have come up with is, my ERC-20 token also implements EIP-1363 and has an approveAndCall(address callee, uint256 amount,bytes extradata) method that approves an amount and calls onApprovalReceived(address owner, uint256 value, bytes memory extradata) on a contract that could then, transfer the tokens to itself, and record the extradata bytes into storage along with the amount, which would serve as proof the order id was paid.

My questions are 1. in the last two years has a better way of accepting ERC-20 been come up with than the previous post's solution? 2. Or is my proposed solution sane?

2
  • Your proposal is good. Here are some better token standard alternatives for ERC-20 that can do single click smart contract transactions: twitter.com/moo9000/status/1326138828013379584 Jan 8, 2021 at 12:48
  • Thank you for this, I will look into them. However for the current proposal, I am obligated to use a specific, already-existing ERC-20 token.
    – Dobit
    Jan 8, 2021 at 12:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.