I need to write a contract that automaticaly mint nfts when tokens are being transferred.
So i have my :
[[eosio::on_notify("*::transfer")]]
void logdeposit(name from,name destination, eosio::asset quantity, std::string memo);
This is working fine and i am able to log incoming deposit on a table.
Now my problem is to understand how can i call actions on the behalf of my contract ?
What i am trying to to for testing is simply to return sent tokens.
So after my log deposits, i try to call this action :
sendtoken(destinationuser,returnedseed,"Returned leftover seeds.");
ACTION seeds1::sendtoken(name to,asset quantity,string memo){
require_auth(get_self());
print("returning : ",quantity.amount," - ",quantity.symbol);
action(
permission_level{get_self(),"active"_n},
name("testseed1"),
name("transfer"),
std::make_tuple(get_self(),to,quantity,"returning seeds")
).send();
}
But that throw me a permission error. So i guess, because the on_notify was trigger by the user transfer it still uses its permission. That is fine for the log deposit action (which record in a table the current user deposit balance).
So here is my question :
- From my log deposit action, how do I call other contract actions with the contract permission (and its important that those actions should only be able to be accessed by the contract, not public)
Thanks a lot :)