aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/cyberdyne/subcurrency.se
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/cyberdyne/subcurrency.se')
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/cyberdyne/subcurrency.se35
1 files changed, 35 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/cyberdyne/subcurrency.se b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/cyberdyne/subcurrency.se
new file mode 100644
index 000000000..1501beff7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/cyberdyne/subcurrency.se
@@ -0,0 +1,35 @@
+# Initialization
+# Admin can issue and delete at will
+init:
+ contract.storage[0] = msg.sender
+code:
+ # If a message with one item is sent, that's a balance query
+ if msg.datasize == 1:
+ addr = msg.data[0]
+ return(contract.storage[addr])
+ # If a message with two items [to, value] are sent, that's a transfer request
+ elif msg.datasize == 2:
+ from = msg.sender
+ fromvalue = contract.storage[from]
+ to = msg.data[0]
+ value = msg.data[1]
+ if fromvalue >= value and value > 0 and to > 4:
+ contract.storage[from] = fromvalue - value
+ contract.storage[to] += value
+ contract.storage[2] = from
+ contract.storage[3] = to
+ contract.storage[4] = value
+ contract.storage[5] += 1
+ return(1)
+ return(0)
+ elif msg.datasize == 3 and msg.sender == contract.storage[0]:
+ # Admin can issue at will by sending a [to, value, 0] message
+ if msg.data[2] == 0:
+ contract.storage[msg.data[0]] += msg.data[1]
+ # Change admin [ newadmin, 0, 1 ]
+ # Set admin to 0 to disable administration
+ elif msg.data[2] == 1:
+ contract.storage[0] = msg.data[0]
+ # Fetch last transaction
+ else:
+ return([contract.storage[2], contract.storage[3], contract.storage[4], contract.storage[5]], 4)