Last active
March 9, 2019 15:03
-
-
Save stablexbt/b09ba73baf922c7af6eb2b477c1b60ea to your computer and use it in GitHub Desktop.
EOSIO Token interface library file
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
| #pragma once | |
| #include <eosiolib/asset.hpp> | |
| #include <eosiolib/eosio.hpp> | |
| #include <string> | |
| namespace eosiosystem { | |
| class system_contract; | |
| } | |
| namespace eosio { | |
| using std::string; | |
| class [[eosio::contract("eosio.token")]] token : public contract { | |
| public: | |
| using contract::contract; | |
| [[eosio::action]] | |
| void create( name issuer, | |
| asset maximum_supply); | |
| [[eosio::action]] | |
| void issue( name to, asset quantity, string memo ); | |
| [[eosio::action]] | |
| void transfer( name from, | |
| name to, | |
| asset quantity, | |
| string memo ); | |
| static asset get_supply( name token_contract_account, symbol_code sym_code ) | |
| { | |
| stats statstable( token_contract_account, sym_code.raw() ); | |
| const auto& st = statstable.get( sym_code.raw() ); | |
| return st.supply; | |
| } | |
| static asset get_balance( name token_contract_account, name owner, symbol_code sym_code ) | |
| { | |
| accounts accountstable( token_contract_account, owner.value ); | |
| const auto& ac = accountstable.get( sym_code.raw() ); | |
| return ac.balance; | |
| } | |
| private: | |
| struct [[eosio::table]] account { | |
| asset balance; | |
| uint64_t primary_key()const { return balance.symbol.code().raw(); } | |
| }; | |
| struct [[eosio::table]] currency_stats { | |
| asset supply; | |
| asset max_supply; | |
| name issuer; | |
| uint64_t primary_key()const { return supply.symbol.code().raw(); } | |
| }; | |
| typedef eosio::multi_index< "accounts"_n, account > accounts; | |
| typedef eosio::multi_index< "stat"_n, currency_stats > stats; | |
| void sub_balance( name owner, asset value ); | |
| void add_balance( name owner, asset value, name ram_payer ); | |
| }; | |
| } /// namespace eosio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment