Every digital currency has to solve the problem of double-spending somehow. What is Stellar's approach to keeping me from spending my money twice at the same time?
Double spending in Stellar is dealt with at two layers:
- SCP guarantees that the "blockchain" (ledger chain really) is made of only one chain, and doesn't have forks (in other systems temporary forks can be created which give different opinions of what the "latest block" is). SCP gives similar guarantees at the consensus layer than PBFT in that validators work in lockstep.
- at the transaction layer, as Stellar is account based, there is also a mechanism to enforce that any given transaction can only be applied once. This is done by using sequence numbers, the gist of it is that to apply a transaction to an account the equivalent of a "test and set" is performed, comparing the counter in the account and the counter in the transaction - if they are compatible (
account number + 1 == tx sequence number) the account is updated with the new counter.
The digital currency is an Asset on Stellar's public ledger only. You can not download it, clone it and spent it again. It exists as a balance on an account that can be transferred to another account on the net with a transaction. The network makes sure that this happens only once and no assets are lost or duplicated.
In a distributed system this is a fairly complex task as you can have any kind of hardware/ network issues as well as malicious actors (see CAP-Theorem). The Stellar Consensus Protocol (SCP) is the solution for this in the Stellar network. If you want to learn more about it, you can watch Professor Mazières’s talk or just start with the graphic novel.