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
| 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; |
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
| public: | |
| using contract::contract; | |
| [[eosio::action]] | |
| void create( name issuer, | |
| asset maximum_supply); | |
| [[eosio::action]] | |
| void issue( name to, asset quantity, string memo ); |
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
| asset token::get_supply( symbol_name sym )const | |
| { | |
| stats statstable( _self, sym ); | |
| const auto& st = statstable.get( sym ); | |
| return st.supply; | |
| } |
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
| asset token::get_balance( account_name owner, symbol_name sym )const | |
| { | |
| accounts accountstable( _self, owner ); | |
| const auto& ac = accountstable.get( sym ); | |
| return ac.balance; | |
| } |
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::create( name issuer, | |
| asset maximum_supply ) | |
| { | |
| require_auth( _self ); | |
| auto sym = maximum_supply.symbol; | |
| eosio_assert( sym.is_valid(), "invalid symbol name" ); | |
| eosio_assert( maximum_supply.is_valid(), "invalid supply"); | |
| eosio_assert( maximum_supply.amount > 0, "max-supply must be positive"); |
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::issue( name to, asset quantity, string memo ) | |
| { | |
| auto sym = quantity.symbol; | |
| eosio_assert( sym.is_valid(), "invalid symbol name" ); | |
| eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" ); | |
| stats statstable( _self, sym.code().raw() ); | |
| auto existing = statstable.find( sym.code().raw() ); | |
| eosio_assert( existing != statstable.end(), "token with symbol does not exist, create token before issue" ); |
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( name from, | |
| 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.code(); | |
| stats statstable( _self, sym.raw() ); |
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
| EOSIO_DISPATCH( eosio::token, (create)(issue)(transfer) ) |
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
| pip3 install boto3 |
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
| import boto3 | |
| # AWS Creds | |
| S3_BUCKET = "BUCKET_NAME" | |
| S3_KEY = "BUCKET_ACCESS_KEY" | |
| S3_SECRET = "BUCKET_SECRET_KEY" | |
| # Create boto3 client connection | |
| s3 = boto3.client( | |
| "s3", |