You might have heard that the Bitcoin blockchain is a public ledger, right? OK, so where is all of the information? Believe it or not, some of it is stored in your wallet file on your PC. Still more is stored on the public blockchain. Keep reading to learn more about where Bitcoin data is stored.
Where do Decentralized Applications Store their Data?
Some blockchains are so powerful that they claim to be a platform for building applications on top of them. Applications automatically turn out to be decentralized, resistant to censorship and blocking. But where is data stored?
- A Peer to Peer File system
IPFS (InterPlanetary File System) is a great example of a peer to peer file system. Instead of a centralized server, IPFS allows files to be stored in a peer to peer fashion, much like Bittorrent. Every file is addressed by hashing its content. The hashes are identifiable since they all start with the letters Qm. Given the hash you will be able to retrieve the file. Store only the content hashes on the blockchain. It allows you to combine file systems on different devices into one, using content addressing. So, while the blockchain stores only the hashes, the hashes themselves provide an easy way to retrieve the large files being stored.
- Distributed file storage (cloud solutions)
This type of storage allows you to merge separate devices into common cloud storage. As a result, users can store their files there just as they could in classic centralized storage, like Dropbox, but cheaper. Owners of devices (farmers), providing a place for storing other peoples files, get money from users according to their contribution. For successful verification passing, the user pays, and the farmer receives a certain amount in cryptocurrency.
This is the approach Ethereum Swarm seems to go for. They aim at replacing the World Wide Web with its centralized servers with a decentralized version. In the same way, DNS is used to look up web pages, Ethereum Swarm uses a Smart Contract called ENS which would allow domain owners to register a reference to their content, even though said content will not be stored in a traditional centralized server.
- Distributed NoSQL databases
NoSQL databases like MongoDB, Cassandra, RethinkDB are able to work with a large number of replicas that are clustered together. The client works with one of the replicas, and the data is automatically synchronized with the others.
NoSQL databases provide eventual consistency, that is, the data is matched after a while when individual replicas are synchronized. In this way they are similar to blockchain the confirmation of a transaction is more likely the more time has passed. These databases can store both a simple key-value and maintain the internal structure of the value, as well as additional indexes.
The problem with that is one malicious node can lead to false information. This is related to a concept called Byzantine Fault Tolerance. It is absolutely crucial to blockchains. In a typical distributed network, even a few malicious nodes can lead to destroying the reliability of the whole system.
As you know, Ethereum is used to build decentralized applications, DAPPs. These applications exist through small programs that live on the Blockchain and are called Smart Contracts. But when somebody writes a Smart Contract, where is the application data Stored?
Let’s assume that “Ethereum is a big, slow, reliable, computer” and it holds a set of accounts. Every account has an owner and a balance (some Ether). But some of these accounts are special, they own themselves. At creation time, we give them a piece of code and memory. That’s a Smart Contract, as a smart bank account.
A DAPP has a balance, some code, and some storage. This storage is persistent, and that’s where we’ll find the data. When a Smart Contract is created or when a transaction awakens it, the Contract’s code can read and write to its storage space.
It’s a big dictionary (key-value store) that maps keys to values.
Keys are strings of 32 bytes. We can have 232 x 8 bits = 2256 different keys. Same for values.
A DAPP and its Smart Contracts may use this storage a page of hard-drive storage in a regular program. 2256 keys x 32 bytes (values) is around 1063 PETABYTES. You would need billions of time the age of the universe to go through this amount of data with an SSD.
We can assume there’s no storage limit for a DAPP. But there is a cost.
The cost of each instruction in a Smart Contract will limit the amount of storage it uses. Ethereum allows for theoretically infinite storage space, BUT you have to provide gas for every read/write operation.
This cost changes all the time: it depends on the network, the market and new developments of the Ethereum specs.
The Blockchain implies a few properties:
- You can read from the Blockchain for free
If you install the Ethereum client and you get into the network. Even without mining, the client will synchronize all the blockchain data. All the data of every DAPP on Ethereum is then available on your machine, without any gas cost.
- Storage Costs doesn’t depend on the duration
Each member of the network may replay the entire history of transactions. By design, the data stored in Ethereum is never deleted, so there’s no benefit to removing a key-value.
Where is the Blockchain Stored?
Blockchain is a time-stamped series of an immutable record of data that is managed by a cluster of computers that is decentralized and not owned by any single authority. Decentralized data storage is usually extremely secure as it cannot be tampered. It is also public and accessible to all the users, so as to maintain transparency.
Digital currencies are all made out of blockchain, it’s the underlying technology behind all cryptocurrencies. It is a huge database storing all information. Imagine it a big spreadsheet where entries can be made by all users and it is instantly updated on all systems.
Blockchains are stored in computers within the system, also named as nodes. So basically it is stored in many simple HDD all around the world. Each node will have a copy of the transaction made. When a new transaction added, all computers storing the blockchain have to update it!
This is where all the details about digital currency transactions ever made are stored:
- Date of the transaction
- Amount sent
- Bitcoin address of the receiver
- Bitcoin address of the sender (it’s a bank account number)
The blockchain is a constantly growing database of transaction information which is sent out to all nodes in the Bitcoin network. When you perform a transaction, that transaction is distributed to the network and assuming the transaction is valid, will be included in the next block. This is where the coins themselves are stored. When you initiate a transaction, all previous transactions to or from that address are scanned and a balance is calculated. If your transaction exceeds this available balance, it will be rejected by the network and will not be included in a block.
The network technically doesnt store coins, but it stores transaction information. The coins themselves are not discrete things which need storage when coins are mined the miners balance is credited via a generate transaction which adds to his or her available balance. When coins are sent from A to B, that transaction subtracts from As balance and adds to Bs balance. This is similar to the way that your employer may, via EFT, send money to your bank and you can use your debit card to spend that money in a store, all without anyone ever seeing a discrete physical dollar bill. Most money in the world today exists merely as transaction histories and balances Bitcoin is no exception.
Where are Bitcoins Stored?
Bitcoin is stored in a place called a “Wallet” a collection of ECDSA keypairs. To be more precise, this digital wallet holds the private key which allows the user to access Bitcoin addresses (also known as a public key). The public key is known to everyone and can be used to encrypt messages in such a way that the holder of the private key alone may decrypt them. The private key may also be used to sign messages in such a way that anyone holding the public key may verify that the message truly came from you.
There are different types of wallets available, so you can choose if you want to store the cryptocurrency on your computer or maybe it should be located on the cloud-based wallet:
- Software Wallets
- Online Wallets
- Mobile wallets
- Hardware Wallets
- Paper wallets
The safety of the digital wallet depends on the format and version of the digital wallet you are using and how it is used. The best option for most is a hardware wallet which will keep you offline and can be stored in a secure place. This wallet will ensure that your account won’t be hacked and your keys are not stolen. If you lose this wallet, your digital currencies will also be lost.
The least secure option is online wallet as third parties hold the keys. Some smart digital currency users opt for hybrid approaches. These investors hold a long-term and core amount of Bitcoin offline while having a spending balance for regular use in a mobile account. User choice will depend on Bitcoin strategy and willingness to get “technical.”
The data is way more secure on a blockchain than if it is stored on the internet. It is much more difficult to breach a blockchain and manipulate any sort of data.