Reputation: 1
I have wrote simple contract that raffles TONs between participants (wallets that deposited into it).
However, I faced such issue, that while sending internal message from my contract to the winner with text comment, I always get TVM exit code 9 (cell underflow). Here is part of my code that fails:
() reward_winner(slice winner_address) impure inline {
var [balance, _] = get_balance();
throw_unless(444, balance > const::min_balance + const::owner_fee);
int withdraw_amount = min(const::winner_reward, balance - const::min_balance - const::owner_fee);
slice winner_congrats = "Congrats to the winner! You have won the raffle!";
cell message_body = begin_cell().store_int(0, 32).store_slice(winner_congrats).end_cell();
int mode = 0;
var msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(winner_address)
.store_coins(withdraw_amount)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
.store_slice(message_body.begin_parse());
send_raw_message(msg.end_cell(), mode);
}
However,if I replace message_body.begin_parse() with just slice winner_congrats, like in code fragment below, everithing works good (except of that text comment is invisible in explorers and wallets):
slice winner_congrats = "Congrats to the winner! You have won the raffle!";
;; cell message_body = begin_cell().store_int(0, 32).store_slice(winner_congrats).end_cell();
int mode = 0;
var msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(winner_address)
.store_coins(withdraw_amount)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
.store_slice(winner_congrats);
send_raw_message(msg.end_cell(), mode);
I am beginner, so maybe I just do not understand something. I need help
Upvotes: 0
Views: 120