So I wanted to do delegatebw in my contract as a deferred transaction:

eosio::transaction out;
out.actions.emplace_back(eosio::permission_level{_self, N(active) }, N(eosio), N(delegatebw), std::make_tuple(_self, someone, stake_net_quantity, stake_cpu_quantity, false));
out.delay_sec = 1;
out.send(id + N(delegate) + current_time(), _self, false);

The values for stake_net_quantity and stake_cpu_quantity are definitely 120 and 80 respectively, however when the code is executed, I get the following error:

2018-08-15T18:09:19.506 thread-0   wasm_interface.cpp:929        eosio_assert         ] message: addition overflow 
2018-08-15T18:09:19.506 thread-0   controller.cpp:612            push_scheduled_trans ] 3050003 eosio_assert_message_exception: eosio_assert_message assertion failure
assertion failure with message: addition overflow
    {"s":"addition overflow"}
    thread-0  wasm_interface.cpp:930 eosio_assert
pending console output: 
    thread-0  apply_context.cpp:61 exec_one
2018-08-15T18:09:19.507 thread-0   apply_context.cpp:28          print_debug          ] 

I looked deep in the code, but there is no way that 120+80 is an addition overflow. Does anyone have any idea what could be happening here?


I have found a solution to my problem.

The problem was caused by the fact that the delegatebw function implicitly calls the transfer function from the contract to the receiver. This, combined with the fact that we have a listening function that waits for transfers to occur and doesn't distinguish between transfers to the account and transfers from the account, caused the listening function to try to parse a gibberish memo. The gibberish memo was placed into assets that were then added together, leading to the addition overflow.

In short, unless you intend to perform actions when you transfer from your account as well as when transfers are received at your account, you should add this in your transfer listening function:

if(transfer.from == _self) return;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.