Several exchanges require a payment ID for deposits and withdraws. What is a payment ID in Monero, and why is it used?
This post from a while back on Reddit documents what a payment ID is and how it is used quite nicely. Note that an integrated address includes a payment ID and is a preferable way to send and receive Monero.
Payment IDs are needed when sending to an exchange, such as Poloniex or to a merchant. It allows Poloniex to confirm the transaction is yours, because Poloniex probably gets a lot of incoming transactions on the same address they won't be able to differentiate otherwise without a payment ID.
Hopefully Poloniex will implement "integrated addresses" in the future, which incorporate the payment ID into the receiving address. This improves user convenience and also mitigates the risk that a user forgets to include payment ID when sending his Monero to an exchange.
How/why to generate a payment ID
Poloniex will provide you with a payment ID, you can include this when sending a transaction from [monero-wallet-cli or monero-wallet-gui]. Conversely, one can generate a payment ID in [monero-wallet-cli or monero-wallet-gui] and include this in the transaction. MyMonero has such an option too.
[When should you not use a payment ID?]
You don't need to include a payment ID when you are sending to another person. For example, if Alice has to send Bob 1000 XMR it is kind of unnecessary to include a payment ID.
The main reason we need payment IDs in XMR is because it isn't convenient to make a new wallet for every new user. By contrast, in Bitcoin one can easily generate another address in a wallet. Therefore, you don't need something like paymentIDs in Bitcoin because the exchange can easily generate a new address for every new user.
For more information, see the page on payment ID's on the official Monero website.
Payment ID is really a message attached to the TX. It can either be encrypted or unencrypted, depending which scheme is used. Usually it's only important when sending to exchanges, services etc. because they use just one address for receiving funds from different users and PID is the only way they can tell apart transactions coming from different users. If you don't specify it, they have no way of telling the funds should be credited to your account (if you forget, it's possible to resolve it by other means, but you'd have to go through extra hoops).
There are 2 ways PID can be transmitted:
- Explicitly specify destination address and payment ID. Some exchanges support only this. With this scheme, the payment ID will be either 64 or 16 hexadecimal characters long. If it's 64 characters long, then the payment ID will also be visible on the blockchain because it will be written unencrypted so you should generate a new one for each deposit. This can also be used for some other things like proof-of-existence and time-stamping documents. If it's 16 characters long, it will be encrypted same way as in the below scheme.
- Send to an integrated address, which has both the destination address and payment ID conveniently packed together. The payment ID is shorter in this case and will consist of 16 hexadecimal characters. This should really be the preferred method, because not only it avoids errors but is also encrypted on the blockchain so you can safely re-use payment IDs and they will appear as different for each TX while only the recipient will be able to decode the actual one being used.
If you're sending to an integrated address then just use:
transfer [address] [amount]. You can recognize it's an integrated address because it's longer (106 characters vs 95 in regular)
If you want to receive something with a specific PID attached, use
integrated_address and give it to your sender. It will generate a random 16-digit PID and encode it together with your regular address into the integrated format. Then, you'll be able to tell apart incoming payments by using
payments [PID] command to filter according to payment ID.
To receive something with explicitly stated PID, just generate any random 64 (or 16) hexadecimal "digits" by any means you like! Then give both your regular address and the payment ID to the sender, and he must be sure not to forget to attach it in the command when sending. That's why integrated format is more convenient.
This does have one interesting practical use. There's nothing stopping the sender from generating some other PID himself. For example, there's one service which took advantage of this and requires user to generate random 16 characters himself and simply pay for the service with that PID attached. Then, the username & password get automatically created from the PID.
A 30-day account will be provisioned for you using th 16 character Payment_ID you provide. UserName = The first 12 characters of your Payment_ID. Password = The 13-16th characters of your Payment_ID. (last 4 digits)