Yes this is possible.
- Create a table with the user's name and whether they are allowed to spend their tokens or not.
- Check this table in the transfer function.
- When the appropriate action is called, update the table entry to permit transfers.
For example:
token code
ACTION transfer(eosio::name from, eosio::name to, eosio::asset quantity, std::string memo){
transfer_not_allowed_table table(contract, scope);
eosio::check(table.find(from.value) == table.end(), "may not transfer");
// rest of transfer code
}
transfer allowed code
TABLE allowed{
eosio::name user;
uint64_t primary_key() const{return user.value;}
};
typedef eosio::multi_index< "allowed"_n, allowed > transfer_not_allowed_table;
ACTION disallow(eosio::name user){
transfer_not_allowed_table table(contract, scope);
eosio::check(table.find(user) == table.end(), "already not allowed to transfer");
table.emplace(_self, [&](auto & entry){
entry.user = user;
});
}
ACTION allow(eosio::name user){
transfer_not_allowed_table table(contract, scope);
eosio::check(table.find(user.value) != table.end(), "already allowed to transfer");
table.erase(table.find(user.value));
}