Wire Sysio Wire Sysion 1.0.0
|
#include <sysio.token.hpp>
Public Types | |
using | create_action = sysio::action_wrapper<"create"_n, &token::create> |
using | issue_action = sysio::action_wrapper<"issue"_n, &token::issue> |
using | retire_action = sysio::action_wrapper<"retire"_n, &token::retire> |
using | transfer_action = sysio::action_wrapper<"transfer"_n, &token::transfer> |
using | open_action = sysio::action_wrapper<"open"_n, &token::open> |
using | close_action = sysio::action_wrapper<"close"_n, &token::close> |
Public Member Functions | |
void | create (const name &issuer, const asset &maximum_supply) |
void | issue (const name &to, const asset &quantity, const string &memo) |
void | retire (const asset &quantity, const string &memo) |
void | transfer (const name &from, const name &to, const asset &quantity, const string &memo) |
void | open (const name &owner, const symbol &symbol, const name &ram_payer) |
void | close (const name &owner, const symbol &symbol) |
Static Public Member Functions | |
static asset | get_supply (const name &token_contract_account, const symbol_code &sym_code) |
static asset | get_balance (const name &token_contract_account, const name &owner, const symbol_code &sym_code) |
The sysio.token
sample system contract defines the structures and actions that allow users to create, issue, and manage tokens for EOSIO based blockchains. It demonstrates one way to implement a smart contract which allows for creation and management of tokens. It is possible for one to create a similar contract which suits different needs. However, it is recommended that if one only needs a token with the below listed actions, that one uses the sysio.token
contract instead of developing their own.
The sysio.token
contract class also implements two useful public static methods: get_supply
and get_balance
. The first allows one to check the total supply of a specified token, created by an account and the second allows one to check the balance of a token for a specified account (the token creator account has to be specified as well).
The sysio.token
contract manages the set of tokens, accounts and their corresponding balances, by using two internal multi-index structures: the accounts
and stats
. The accounts
multi-index table holds, for each row, instances of account
object and the account
object holds information about the balance of one token. The accounts
table is scoped to an EOSIO account, and it keeps the rows indexed based on the token's symbol. This means that when one queries the accounts
multi-index table for an account name the result is all the tokens that account holds at the moment.
Similarly, the stats
multi-index table, holds instances of currency_stats
objects for each row, which contains information about current supply, maximum supply, and the creator account for a symbol token. The stats
table is scoped to the token symbol. Therefore, when one queries the stats
table for a token symbol the result is one single entry/row corresponding to the queried symbol token if it was previously created, or nothing, otherwise.
Definition at line 25 of file sysio.token.hpp.
using sysio::token::close_action = sysio::action_wrapper<"close"_n, &token::close> |
Definition at line 123 of file sysio.token.hpp.
using sysio::token::create_action = sysio::action_wrapper<"create"_n, &token::create> |
Definition at line 118 of file sysio.token.hpp.
using sysio::token::issue_action = sysio::action_wrapper<"issue"_n, &token::issue> |
Definition at line 119 of file sysio.token.hpp.
using sysio::token::open_action = sysio::action_wrapper<"open"_n, &token::open> |
Definition at line 122 of file sysio.token.hpp.
using sysio::token::retire_action = sysio::action_wrapper<"retire"_n, &token::retire> |
Definition at line 120 of file sysio.token.hpp.
using sysio::token::transfer_action = sysio::action_wrapper<"transfer"_n, &token::transfer> |
Definition at line 121 of file sysio.token.hpp.
This action is the opposite for open, it closes the account owner
for token symbol
.
owner | - the owner account to execute the close action for, |
symbol | - the symbol of the token to execute the close action for. |
Definition at line 148 of file sysio.token.cpp.
Allows issuer
account to create a token in supply of maximum_supply
. If validation is successful a new entry in statstable for token symbol scope gets created.
issuer | - the account that creates the token, |
maximum_supply | - the maximum supply set for the token created. |
Definition at line 5 of file sysio.token.cpp.
|
inlinestatic |
Definition at line 111 of file sysio.token.hpp.
|
inlinestatic |
Definition at line 104 of file sysio.token.hpp.
This action issues to to
account a quantity
of tokens.
to | - the account to issue tokens to, it must be the same as the issuer, |
quantity | - the amount of tokens to be issued, @memo - the memo string that accompanies the token issue transaction. |
Definition at line 26 of file sysio.token.cpp.
Allows ram_payer
to create an account owner
with zero balance for token symbol
at the expense of ram_payer
.
owner | - the account to be created, |
symbol | - the token to be payed with by ram_payer , |
ram_payer | - the account that supports the cost of this action. |
More information can be read here and here.
Definition at line 128 of file sysio.token.cpp.
The opposite for create action, if all validations succeed, it debits the statstable.supply amount.
quantity | - the quantity of tokens to retire, |
memo | - the memo string to accompany the transaction. |
Definition at line 52 of file sysio.token.cpp.
void sysio::token::transfer | ( | const name & | from, |
const name & | to, | ||
const asset & | quantity, | ||
const string & | memo ) |
Allows from
account to transfer to to
account the quantity
tokens. One account is debited and the other is credited with quantity tokens.
from | - the account to transfer from, |
to | - the account to be transferred to, |
quantity | - the quantity of tokens to be transferred, |
memo | - the memo string to accompany the transaction. |
Definition at line 76 of file sysio.token.cpp.