I'm trying to better understand how to implement smart contracts with tokens built on top of Ethereum. Before diving too deeply into the implementation details with Solidity, I'd like to understand possible roadblocks.
I'd like to understand better how data is carried in smart contracts, and how something like "colored coins" from Bitcoin lingo might work.
So, I've come up with an example of how I think that smart contracts could be used based on what I've read: Beervesting.
For my example, I came up with a new token: BeerCoins
Let's say these BeerCoins are created by mining, and breweries may want to purchase or mine them to create a beer futures market... maybe they want to sell their beer at a discount before they begin brewing it.
Here are a few types of transactions that I think could be done with these BeerCoins:
Transaction 1 - Alice buys BeerCoins
So, let's say that Alice is a savvy beer drinker, and she wants to buy her beer in advance for a discount using Ethereum. She can redeem her beer once it's been brewed (in 2 months).
Alice trades Ethereum for BeerCoins, and the BeerCoins now change state: They're redeemable for 1 pint of beer each.
Transaction 2 - Alice sells some BeerCoins to Bob
Now, perhaps some time goes by, and Bob wants to get in on this BeerCoin action. He doesn't want to wait for the next batch; he'd like to buy some of the current batch. He's got a party coming up in the next few weeks, and good beer takes a couple of months to brew. Alice decides to give some (full) BeerCoins to Bob in exchange for some Bitcoins.
Transaction 3 - Bob redeems BeerCoins for Beer
Now, Bob's ready to have his party, so he sends some of his BeerCoins back to the Brewery, and they ship him beer. The Brewery attaches a tracking number to transaction, and the BeerCoins are transferred and emptied as soon as the beer is delivered (as reported by an oracle, the shipping company).
So my question is:
Is this smart contract implementation possible? Can Ethereum tokens carry a state in this way?
Are there any good examples for this kind of implementation?
I think there are a few things to consider:
- How to store/modify state data in a token? Are there best practices?
- How much data can practically be stored in a token?
Thanks in advance for the help.