To understand where the data is stored, you will first need to look at what are wallets and blockchain:
- A “wallet” is a collection of ECDSA keypairs. In other words, a keypair consists of a “public key” and a “private key” which can be used to encrypt or sign bits of data. The public key (as the name suggests) is something that is known by everybody and used to encrypt messages in a way that only the holder of the private key may decrypt them. The private key on the other hand 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. Each and every Bitcoin address consists of such a keypairs which is made up of the “address” you send people which is the public half and the private half which resides in your wallet.
- The “blockchain” is a constantly growing database of transaction information which is sent out to all nodes in the Bitcoin network. When a transaction is performed, that transaction is distributed to the network and assuming the transaction is valid (after confirmation), will be included in the next “block.” This is where the coins themselves are stored. When a transaction is initiated, all previous transactions to or from that address are scanned and a balance is calculated. If the new transaction exceeds this available balance, it will be rejected by the network and will not be included in a block.
It’s also important to note that the blockchain technically doesn’t store “coins” it stores transaction information.
jackson Edited answer