In general, there are three types of applications on top of Ethereum. The first category is
financial applications, providing users with more powerful ways of managing and entering
into contracts using their money. This includes sub-currencies, financial derivatives,
hedging contracts, savings wallets, wills, and ultimately even some classes of full-scale
employment contracts. The second category is semi-financial applications, where money
is involved but there is also a heavy non-monetary side to what is being done; a perfect
example is self-enforcing bounties for solutions to computational problems. Finally, there
are applications such as online voting and decentralized governance that are not financial
at all.
Token Systems
On-blockchain token systems have many applications ranging from sub-currencies
representing assets such as USD or gold to company stocks, individual tokens
representing smart property, secure unforgeable coupons, and even token systems with
no ties to conventional value at all, used as point systems for incentivization. Token
systems are surprisingly easy to implement in Ethereum. The key point to understand is
that a currency, or token system, fundamentally is a database with one operation: subtract
X units from A and give X units to B, with the provision that (1) A had at least X units
before the transaction and (2) the transaction is approved by A. All that it takes to
implement a token system is to implement this logic into a contract.
The basic code for implementing a token system in Serpent looks as follows:
def send(to, value):
if self.storage[msg.sender] >= value:
self.storage[msg.sender] = self.storage[msg.sender] - value
self.storage[to] = self.storage[to] + value
This is essentially a literal implementation of the "banking system" state transition function
described further above in this document. A few extra lines of code need to be added to
provide for the initial step of distributing the currency units in the first place and a few
other edge cases, and ideally a function would be added to let other contracts query for