I have a very simple ACTION in a contract that writes to a table (multi-index) which has two columns: a string name and an auto-generated primary key called id.
This part works fine and I am able to push an action to insert to this table. However, my next step is to test whether or not I can send a context free action from the previous action that created the row so that another action can use the ID generated from the first action and do something with it.
For simplicity's sake, the second action just prints the supplied ID.
I am fairly certain it is the way I am populating the action object but I can't seem to find anything to show me how to do it correctly. Here is the code snippet that populates the action object and calls the send_context_free() method:
[...]
// now send the context free action action act;
act.account = _self;
act.name = name("reportid");
act.data = {static_cast<char>(itr->id)};
act.send_context_free();
}
and here is the reportid function that send_context_free() is invoking:
ACTION reportid(uint64_t id)
{
print("context free inline action reports ID: ",id);
}
I'd appreciate any guidance as I am unable to get this to work. When I push the first ACTION, I get
Error 3050003: eosio_assert_message assertion failure
and the detailed log entries are:
2018-10-16T19:13:17.655 thread-0 apply_context.cpp:28 print_debug ]
[(eossocaltest,additem)->eossocaltest]: CONSOLE OUTPUT BEGIN =====================
The unique ID of the added Item record Hello EOSSOCAL 108 is 5
[(eossocaltest,additem)->eossocaltest]: CONSOLE OUTPUT END =====================
2018-10-16T19:13:17.655 thread-0 wasm_interface.cpp:929 eosio_assert ] message: read
2018-10-16T19:13:17.656 thread-0 http_plugin.cpp:580 handle_exception ] FC Exception encountered while processing chain.push_transaction
2018-10-16T19:13:17.656 thread-0 http_plugin.cpp:581 handle_exception ] Exception Details: 3050003 eosio_assert_message_exception: eosio_assert_message
assertion failure
assertion failure with message: read
{"s":"read"}
thread-0 wasm_interface.cpp:930 eosio_assert
pending console output:
{"console":""}
thread-0 apply_context.cpp:61 exec_one