You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
#pragma version >=0.2.0; |
|
|
|
#include "stdlib.fc"; |
|
|
|
() send_grams(slice address, int amount) impure { |
|
cell msg = begin_cell() |
|
.store_uint (0x18, 6) ;; bounce |
|
.store_slice(address) ;; 267 bit address |
|
.store_grams(amount) |
|
.store_uint(0, 107) ;; 106 zeroes + 0 as an indicator that there is no cell with the data |
|
.end_cell(); |
|
send_raw_message(msg, 3); ;; mode, 2 for ignoring errors, 1 for sender pays fees, 64 for returning inbound message value |
|
} |
|
|
|
int workchain() asm "0 PUSHINT"; |
|
|
|
() force_chain(slice addr) impure { |
|
(int wc, _) = parse_std_addr(addr); |
|
throw_unless(333, wc == workchain()); |
|
} |
|
|
|
cell pack_jetton_wallet_data(int balance, slice owner_address, slice jetton_master_address, cell jetton_wallet_code) inline { |
|
return begin_cell() |
|
.store_coins(balance) |
|
.store_slice(owner_address) |
|
.store_slice(jetton_master_address) |
|
.store_ref(jetton_wallet_code) |
|
.end_cell(); |
|
} |
|
|
|
cell calculate_jetton_wallet_state_init(slice owner_address, slice jetton_master_address, cell jetton_wallet_code) inline { |
|
return begin_cell() |
|
.store_uint(0, 2) |
|
.store_dict(jetton_wallet_code) |
|
.store_dict(pack_jetton_wallet_data(0, owner_address, jetton_master_address, jetton_wallet_code)) |
|
.store_uint(0, 1) |
|
.end_cell(); |
|
} |
|
|
|
slice calculate_jetton_wallet_address(cell state_init) inline { |
|
return begin_cell() |
|
.store_uint(4, 3) |
|
.store_int(workchain(), 8) |
|
.store_uint(cell_hash(state_init), 256) |
|
.end_cell() |
|
.begin_parse(); |
|
} |
|
|
|
slice calculate_user_jetton_wallet_address(slice owner_address, slice jetton_master_address, cell jetton_wallet_code) inline { |
|
return calculate_jetton_wallet_address(calculate_jetton_wallet_state_init(owner_address, jetton_master_address, jetton_wallet_code)); |
|
}
|
|
|