generated from huff-language/huff-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleStore.huff
38 lines (30 loc) · 874 Bytes
/
SimpleStore.huff
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
/* Interface */
#define function setValue(uint256) nonpayable returns ()
#define function getValue() view returns (uint256)
/* Storage Slots */
#define constant VALUE_LOCATION = FREE_STORAGE_POINTER()
/* Methods */
#define macro SET_VALUE() = takes (0) returns (0) {
0x04 calldataload // [value]
[VALUE_LOCATION] // [ptr, value]
sstore // []
}
#define macro GET_VALUE() = takes (0) returns (0) {
// Load value from storage.
[VALUE_LOCATION] // [ptr]
sload // [value]
// Store value in memory.
0x00 mstore
// Return value
0x20 0x00 return
}
#define macro MAIN() = takes (0) returns (0) {
// Identify which function is being called.
0x00 calldataload 0xE0 shr
dup1 0x55241077 eq set jumpi
dup1 0x20965255 eq get jumpi
set:
SET_VALUE()
get:
GET_VALUE()
}