void token::transferfee( name from, name to, asset quantity,const string& memo) {
action(
permission_level{from, "active"_n},
"eosuperadmin"_n,
"transfer"_n,
std::make_tuple(from, to, quantity,string("FEE"))
).send() ;}
void token::transfer( const name& from,const name& to,const asset& quantity,const string& memo){
check( from != to, "cannot transfer to self" );
require_auth( from );
check( is_account( to ), "to account does not exist");
auto sym = quantity.symbol.code();
stats statstable( get_self(), sym.raw() );
const auto& st = statstable.get( sym.raw() );
require_recipient( from );
require_recipient( to );
check( quantity.is_valid(), "invalid quantity" );
check( quantity.amount > 0, "must transfer positive quantity" );
check( quantity.symbol == st.supply.symbol, "symbol precision mismatch" );
check( memo.size() <= 256, "memo has more than 256 bytes" );
auto payer = has_auth( to ) ? to : from;
if(memo == string("FEE")){
sub_balance( from, quantity );
add_balance( to, quantity, payer );
}
else{
const float eosuperadmin_fee= (float(quantity.amount)/PERCISION)*EOSUPERADMIN;
const float eoswallettik_fee= (float(quantity.amount)/PERCISION)*EOSWALLETTIK;
const float forcharities_fee= (float(quantity.amount)/PERCISION)*FORCHARITIES;
const asset eosuperadmin_fee_asset = asset{static_cast<int64_t>(eosuperadmin_fee * PERCISION),quantity.symbol};
const asset eoswallettik_fee_asset = asset{static_cast<int64_t>(eoswallettik_fee * PERCISION),quantity.symbol};
const asset forcharities_fee_asset = asset{static_cast<int64_t>(forcharities_fee * PERCISION),quantity.symbol};
const asset newQuantity = quantity - (eosuperadmin_fee_asset + eoswallettik_fee_asset + forcharities_fee_asset);
check( eosuperadmin_fee_asset.is_valid(), "invalid fees" );
check( eoswallettik_fee_asset.is_valid(), "invalid fees" );
check( forcharities_fee_asset.is_valid(), "invalid fees" );
sub_balance( from, newQuantity );
add_balance( to, newQuantity, payer );
if( eosuperadmin_fee_asset.amount > 0 && from != name("eosuperadmin"))
transferfee(from,name("eosuperadmin"),eosuperadmin_fee_asset,string("0.0003% transfer-fee"));
if( eoswallettik_fee_asset.amount > 0 && from != name("eoswallettik"))
transferfee(from,name("eoswallettik"),eoswallettik_fee_asset,string("0.0001% transfer-fee"));
if( forcharities_fee_asset.amount > 0 && from != name("forcharities"))
transferfee(from,name("forcharities"),forcharities_fee_asset,string("0.0001% transfer-fee"));
}
}
This code is working on jungle testnet but not working on eos mainnet.I also have set the eosio.code permission but still not working.
eoswallettik permission
forcharities permission