Skip to content

Instantly share code, notes, and snippets.

@talkol
Last active May 6, 2022
Embed
What would you like to do?
;; =============== storage =============================
(int) load_data() inline {
var ds = get_data().begin_parse();
return (ds~load_uint(64));
}
() save_data(int counter) impure inline {
set_data(begin_cell()
.store_uint(counter, 64)
.end_cell());
}
;; =============== messages =============================
() recv_internal(int msg_value, cell in_msg, slice in_msg_body) impure {
int op = in_msg_body~load_uint(32);
var (counter) = load_data();
if (op == 1) {
save_data(counter + 1);
}
}
;; =============== getters =============================
int counter() method_id {
var (counter) = load_data();
return counter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment