1

I am looking for a payment solution for my website using crypto. I have seen some websites that display a modal with a QR code and a recipient address. I wonder how they know if someone has deposited funds into that wallet address in order to credit the payment. Usually, with payment gateways, they can transmit additional parameters (such as orderId) and a callback address to confirm that the ID exists in the database.

I don't want to use a third party. I am using the etherjs or web3js library, but the issue is how can I know which user has made a payment for something? Currently, the only thing I can do is retrieve the payment amount.

The problem is that I cannot confirm which user made the payment if the website does not require updating the wallet address before making the payment.

Other websites only have a QR code and the payment amount. How did they manage to solve this?

enter image description here

2 Answers 2

2

There are two common ways to associate a payment with a user.

a. Generate a new address. You can generate millions of deposit addresses - so you will get this User⇆Wallet relation. But you need to spend more gas later to collect assets.

b. Put user-related bits into the Total amount. Then you will need to have one wallet where you will receive all the payments and by the amount you can detect the user making the payment. The user bits amount shouldn't be unique in total, as the user has time for deposits, which means you can rotate the number once a week or so. Additionally, you can have multiple addresses (let's say 20 - to receive deposits). (From the screenshot above, it looks like the 581 is the user-related info)


After you create the amount and the address you start listening for the incoming balance.

a. If you go the User⇆Wallet way, you must just check the balance in intervals. With the second option, it won't work, as you check the complete balance of your wallet.

b. With Total amount you must monitor the Transfer(from,to,amount) events in USDT contract.

1
1

Here are two ways you could relate the user to the crypto payment:

  1. Centralized Database: You could spin-up a database, like SQL, MongoDB, or a headless CMS that relates user <-> crypto payment in the backend, when the click the deposit button on your website. Your server could then monitor the status of the transactions and thus the user's payment status.

  2. Smart Contract Sotrage: Instead of the user directly sending ERC-20 to your deposit address, you could create an intermediate proxy that stores some extra information in a mapping and then transfers the ERC-20. The user would first have to approve your intermediate proxy though.

2
  • 1
    so with solutions 1 how to know who has deposit ?
    – Peter Jack
    Jun 11, 2023 at 19:23
  • If I understand this correctly, when the user clicks "deposit" on your frontend, get the current metamask wallet connected to the frontend, and then before you send a request to metamask to get the user to sign the transaction, save the address connected to the frontend.
    – Danny B
    Jun 12, 2023 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.