https://gitlab.com/tezos/tezos
Raw File
Tip revision: 0af68dc7c6c2a2bf9c2d7b3412de733610ae081f authored by Arvid Jakobsson on 23 February 2024, 09:47:15 UTC
An empty commit
Tip revision: 0af68dc
king_of_tez.tz
parameter key_hash;
storage (pair timestamp (pair mutez key_hash));
code { DUP; CDAR;
       # If the time is more than 2 weeks, any amount makes you king
       NOW; CMPGT;
       # User becomes king of mutez
       IF { CAR; AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR;
            NIL operation }
          # Check balance to see if user has paid enough to become the new king
          { DUP; CDDAR; AMOUNT; CMPLT;
            IF { FAIL }             # user has not paid out
               { CAR; DUP;
                 # New storage
                 DIP{ AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR };
                 # Pay funds to old king
                 IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS;
                 NIL operation; SWAP; CONS}};
       # Cleanup
       PAIR };
back to top