-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreeter.lll
53 lines (39 loc) · 1.44 KB
/
greeter.lll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;;;; ==========================================================================
;;;; @title Lovely Little Greeter
;;;; @author Noel Maersk <veox>
(seq
(include "../common.lll.inc")
;; ==========================================================================
;; STORAGE LAYOUT
(def '*storloc-greeting* 0x1337)
;; ==========================================================================
;; CONSTANTS
(def '*initial-greeting* 42)
(def '*greet* 0xcfae3217) ; greet()
(def '*greeting* 0xef690cc0) ; greeting(): public storage in Solidity
(def '*set-greeting* 0xb2010978) ; setGreeting(uint256)
;; ==========================================================================
;; INIT
(seq
unpayable
(sstore *storloc-greeting* *initial-greeting*))
;; ==========================================================================
;; CODE
(returnlll
(seq
unpayable
mstore-function-selector
;; change greeting value in storage
(def 'new-greeting (calldataload 0x04))
(function *set-greeting*
(seq
(sstore *storloc-greeting* new-greeting)
(stop)))
;; return greeting value from storage
(function *greet*
(return (sload *storloc-greeting*)))
;; for compatibility with Greeter.sol: "public storage variable"
(function *greeting*
(return (sload *storloc-greeting*)))
;; fallback
(panic))))