1

I'm currently building up a service where the user can deposit multiple cryptos. One of them is Monero, and that is where I'm stuck at the moment.

I use PHP for this and the following project: https://github.com/monero-integrations/monerophp

I tried to play around and thought the best way would be the following: - generate an address - check for incoming transfers of the given address

The problem is, that I can generate the address but anyway, when I'm using incoming_transfers or get_transfers, neither I get the needed transactions. I get all of the transactions belonging to the wallet.

Maybe I misunderstood the concept (accounts, addresses, subadresses) as Monero is rather new to me. Can somebody give me a hint what would be the best way to archive the result I want?

I don't need any code, just point me into the right direction, so I can have a look at it! :)

Thanks in advance guys!

1 Answers1

2

I would suggest creating a subaddress per customer. Therefore, you will be calling the RPC method create_address (if using the monero-wallet-rpc directly), or the equivalent method in your referenced PHP wrapper library.

To check for incoming payments, you can use incoming_transfers (or the equivalent library method). Depending on your use case, you can request all subaddress incoming payments (e.g. don't supply the optional subaddr_indices parameter), or specific subbaddresses by specififying their respective indices in the subaddr_indices array parameter. An even better approach is to make use of the monero-wallet-rpc parameter --tx-notify which will execute a program each time you receive a payment, thus preventing the need for polling.

monero-wallet-rpc --help
...
  --tx-notify arg                   Run a program for each new incoming 
                                    transaction, '%s' will be replaced by 
                                    the transaction hash

You can then check which subaddress was deposited to by using get_transfer_by_txid.

A good overview of accounts and subaddresses can be found at https://monerodocs.org/public-address/subaddress/.

jtgrassie
  • 19,601
  • 4
  • 17
  • 54