Yes.
A Bitcoin "transaction" is actually a short Forth-like program running on a stack-based, non-Turing complete virtual machine. When Bitcoin has been sent to an address, the output script of a transaction is something like this:
let HASH = "xxxxxxxxxxxxxxxxxxxxxx";
if (check(HASH, pubkey, signature) == True)
return 1;
return 0;
And recall a Bitcoin address is a RIPEMD-160 hash, which means any 20 bytes binary data is a legitimate Bitcoin address. So earliest and simplest method of storing data is simply submitting a payment that sends pennies to a bunch of garbage Bitcoin addresses corresponding to your binary data.This method was controversial in the early days, as it created a lot of not-actual-transaction garbage in the blockchain. Bitcoin developers later introduced opcode "OP_RETURN", which is seen as a standard and less-evil way to post data. In this case, the script is something like:
let DATA = "xxxxxxxxxxxxxxxxxxxxxx";
return 0;
Also, from the perspective of the system, it's just a transaction. Although for a OP_RETURN transaction, it won't be added to the UTXO (unspent transactions) list, because the script always returns false, it's not spendable.The limitation of using Bitcoin blockchain as a data storage medium is the astronomical transaction fee. The larger the transaction (i.e. the script), the higher the fee. Typically, nobody can afford to store more than a few hundred bytes.
> Bitcoin developers later introduced opcode "OP_RETURN", which is seen as a standard and less-evil way to post data.
This is not true and an error in the Mastering Bitcoin book. OP_RETURN was introduced by Satoshi in the very first version of bitcoin.
> Typically, nobody can afford to store more than a few hundred bytes.
This depends on the artificial constraints put on the network. Bottle operates on top of BSV which comes without a cap on supply and offers cheaper fees when compared to BTC.
See example of weather data stored on chain https://whatsonchain.com/tx/6dac238576e9778458bb62a2f7d936fd...
>are there fees to host this data (as we need to pay miners to include data in a block)?
Yes, current fees are about 1 sat/byte.
This is really a write once, read many type of system.
What's a sat?
Not so much for backing up your photo collection, but more along the lines of publishing some textual information that someone powerful does not want published. It could even potentially function as a sort of notary service.
Fell down the rabbit hole and found these: