aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/eth15/map.se
blob: 768dfb9fc71f107df96ba8071506cb44d60161ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# An implementation of a contract for storing a key/value binding
init:
    # Set owner
    contract.storage[0] = msg.sender
code:
    # Check ownership
    if msg.sender == contract.storage[0]:
        # Get: returns (found, val)
        if msg.data[0] == 0:
            s = sha3(msg.data[1])
            return([contract.storage[s], contract.storage[s+1]], 2)
        # Set: sets map[k] = v
        elif msg.data[0] == 1:
            s = sha3(msg.data[1])
            contract.storage[s] = 1
            contract.storage[s + 1] = msg.data[2]
        # Suicide
        elif msg.data[2] == 1:
            suicide(0)