I'm looking for a way to expose some type of data publicly without providing my private view key to the public. Is there a way to expose payment id's in block explorers? Or is there some other way of exposing this?
There are two types of payment ID. The first is the older style 32 byte unencrypted payment ID. This will appear on the blockchain for anyone to see.
The second type is the newer style 8 byte encrypted payment ID. That gets encrypted with the transaction shared secret before hitting the blockchain, so that would not be suitable.
Monero has a tx_extra field that can be of any length, so you could even create specially formed transactions that could put much more than 32 bytes unencrypted onto the blockchain. The structure of the tx_extra field is described here: https://cryptonote.org/cns/cns005.txt
Here is an example transaction on the blockchain: https://xmrchain.net/tx/91be5c4bf7afa2a80bdb82db4eacefa8a212aefed41cca75f06e83f16ebef742
The tx_extra field is:
The first byte
02 means the first field is of type "tx_extra_nonce", which means either an encrypted or unencrypted payment id will follow. The second byte is a varint
21 which means that the field we're about to read is 33 bytes long (21 in hex is 33 in decimal).
Therefore the "tx_extra_nonce" field is the following 33 bytes:
The first byte of the field is
00 which means the rest of the field is a 32 byte unencrypted payment id:
If the first byte of the tx_extra_nonce field was
01, then an 8 byte encrypted payment id would have followed.
For completeness, note that the next field in the tx_extra is marked as type
01. This means that the 32 byte transaction public key follows.
The transaction public key is: