Created
January 8, 2022 15:05
-
-
Save MCarlomagno/b0dfffa886cea1f52b46f761de1307b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
sub_balance( from, quantity ); | |
add_balance( to, quantity, payer ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment