{ ;; Constant values ;; Price base (wei), doubled for each definition up to DEFS-COUNT (def 'PRICE-BASE 10) ;; Add to the index to get the price base exponent (def 'PRICE-FACTOR-ADD 10) ;; Number of definitions (def 'DEFS-COUNT 12) ;; Range of values for definitions (def 'DEF-MIN 0x1) (def 'DEF-MAX 0x0F0F0F0F) ;; Storage locations (def 'artist 0x10) (def 'defs-base 0x100) (def 'theorists-base 0x200) ;; State ;; Contract owner/payee [[artist]] (caller) (return 0x0 (lll { [action] (calldataload 0) (when (= @action "set") { [index] (calldataload 32) [definition] (calldataload 64) [price] (exp PRICE-BASE (+ @index 1 PRICE-FACTOR-ADD)) ;; If the index is in range and the caller paid enough to set it (when (&& (>= @definition DEF-MIN) (<= @definition DEF-MAX) (< @index DEFS-COUNT) (= (callvalue) @price)) { ;; Update definition [[(+ defs-base @index)]] @definition [[(+ theorists-base @index)]] (caller) (- (gas) 100) @@artist @price 0 0 0 0 }) }) } 0x0)) }