Token Systems
Last updated
Last updated
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 Arcturus. The key point to understand is that all a currency, or token system, fundamentally is, is a database with one operation: subtract units from and give units to , with the proviso that (i) had at least units before the transaction and (ii) the transaction is approved by . 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:
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 the balance of an address. But that's all there is to it. Theoretically, Arcturus-based token systems acting as sub-currencies can potentially include another important feature that on-chain Bitcoin-based meta-currencies lack: the ability to pay transaction fees directly in that currency.
The way this would be implemented is that the contract would maintain an Arcturus balance with which it would refund Arcturus used to pay fees to the sender, and it would refill this balance by collecting the internal currency units that it takes in fees and reselling them in a constant running auction. Users would thus need to "activate" their accounts with Arcturus, but once the Arcturus is there it would be reusable because the contract would refund it each time.