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 am new to crypto and i am also trying to use same above project but don't know how to use it Do I need to install monero wallet first in my pc/hosting? To user monero wallet commands? I am trying to build monero exchange I have knowledge of php and already developed many websites in php
    – Usama
    Commented Oct 29, 2019 at 23:06

1 Answer 1

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

3
  • 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. :/ Commented Jul 1, 2019 at 10:45
  • 1
    subaddr_indices is an array of integers, not the actual address(es).
    – jtgrassie
    Commented Jul 1, 2019 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! :-) Commented Jul 3, 2019 at 11:43

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.