Tutorial 2: Rainbow Coin

Loading...
def init():
	self.storage[msg.sender + (0 * 2**160)] = 10000 #Red
	self.storage[msg.sender + (1 * 2**160)] = 10000 #Orange
	self.storage[msg.sender + (2 * 2**160)] = 10000 #Yellow
	self.storage[msg.sender + (3 * 2**160)] = 10000 #Green
	self.storage[msg.sender + (4 * 2**160)] = 10000 #Blue
	self.storage[msg.sender + (5 * 2**160)] = 10000 #Indigo
	self.storage[msg.sender + (6 * 2**160)] = 10000 #Violet
def code():
	to = msg.data[0]
	from = msg.sender
	value = msg.data[1]
	coin = msg.data[2]
	if self.storage[from + (coin * 2**160)] >= value and to <= 2**160:
		self.storage[from + (coin * 2**160)] = self.storage[from +(coin * 2**160)]  - value
		self.storage[to + (coin * 2**160)] = self.storage[to+ (coin * 2**160)] + value

Serpent contract for Ethereum

Tutorial 2: Rainbow Coin. https://forum.ethereum.org/discussion/1635/tutorial-2-rainbow-coin#

Preferences

Note: Your changes won't be saved, because not Logged-in.

Create your own Contract