Custom and numbered work examples updated to work without byte arrays. Revisit this...
[robmyers:artworld-ethereum.git] / serpent / transferrable_stored_work.se
1 init:
2     ARTIST = 0x8802b7f0bfa5e9f5825f2fc708e1ad00d2c2b5d6
3     OWNER = 1001
4     // Initialize the owner to be the artist
5     contract.storage[OWNER] = ARTIST
6 code:
7     OWNER = 1001
8     ARTWORK = "The art happens here."
9     // Make sure we have enough gas to run the contact
10     if tx.value < tx.basefee * 200:
11         // If not, stop
12         stop
13
14     // If the message is from the current owner
15     // and there are enough arguments
16     // and the command to transfer is being given
17     if msg.sender == contract.storage[OWNER] and msg.datasize == 2 and msg.data[0] == "transfer":
18         // Transfer it to a new owner
19         contract.storage[OWNER] = msg.data[1]
20         return(1)
21     // If there are enough arguments
22     // and the command to show the work is being given
23     else if (msg.datasize == 1):
24         // Just return the artwork
25         return(ARTWORK)
26     // Otherwise
27     else:
28         // Logical false for failure
29         return(0)