I have written an action transfer in my contract which is as below
// @abi action
void second::transfer( account_name from,
account_name to,
asset quantity,
string memo )
{
eosio_assert( from != to, "cannot transfer to self" );
require_auth( from );
eosio_assert( is_account( to ), "to account does not exist");
auto sym = quantity.symbol.name();
stats statstable( _self, sym );
const auto& st = statstable.get( sym );
require_recipient( from );
require_recipient( to );
eosio_assert( quantity.is_valid(), "invalid quantity" );
eosio_assert( quantity.amount > 0, "must transfer positive quantity" );
eosio_assert( quantity.symbol == st.supply.symbol, "symbol precision mismatch" );
eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" );
//print("balance of account from before transaction______",from.balance.amount);
print("before transaction ______________________________account before_____________________________________________");
asset value;
printBalance(from,value);
printBalance(to,value);
sub_balance( from, quantity );
add_balance( to, quantity, from );
printBalance(from,value);
printBalance(to,value);
print("transfer _____________________account after________________________________________________________");
}
My contract name is second and I set the contract with my account name firstname , I also have a second account secondname and i set the permission as given
cleos --wallet-url http://wallet:5555 -u http://server:7777 set account permission firstname active '{"threshold": 1,"keys": [{"key": "EOS5BbbeRJizvAUq27RLFXWtabMfVgs9MjYUBJ8Y5cwvoDCYnnPyp","weight": 1}],"accounts": [{"permission":{"actor":"firstname","permission":"eosio.code"},"weight":1}]}' owner -p firstname
I had issued 10000.0000 EOS to account firstname, but when I send EOS from firstname to secondname using the following command
cleos --wallet-url http://wallet:5555 -u http://server:7777 push action firstname transfer '[ "firstname", "secondname", "1.0001 EOS", "message"]' -p firstname
I get the following error : 845758ms thread-0 main.cpp:2350 main ] Failed with error: Assert Exception (10) condition: assertion failed: unable to find key
my wallet is unlocked and running on port 5555 and nodeos running on port 7777. Am I doing something wrong while setting permission ?
PS: I am a little bit unclear about setting permissions.