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

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/.

  • Thanks for your response, that is likely the way I was doing it already but incoming_transfers gives me back all transactions of the account. Creating the sub address is fine and works very well. I tried using incoming_transfers with the address itself as subaddress_indices or using an integer. This really bugs me, I cant see any fault. :/ – FrustratedCoder Jul 1 at 10:45
  • subaddr_indices is an array of integers, not the actual address(es). – jtgrassie Jul 1 at 11:12
  • THANKS! That was the problem, I just tried using the index as integer, wrapping it up in an array brought the correct result! :-) – FrustratedCoder Jul 3 at 11:43

Your Answer

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

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