GFL token standard is a set of rules that all tokens on a blockchain must follow. This allows for interoperability between different tokens and applications.
{% note tip %}
GlobalForce tokens support more than one token per contract, however in practice not many contracts will do this.
{% endnote %}
[[eosio::action]]
void create(const name& issuer, const asset& maximum_supply);
Creates a new token with a maximum supply limit, and sets the issuer account.
The symbol
of the asset
defined the precision (decimals) and the token ticker.
For instance, a maximum supply of 1000.0000 XYZ
means that the token has a precision of 4 decimals,
a ticker of XYZ
, and a maximum supply of 1000
.
Parameters:
issuer
- The account that creates the tokenmaximum_supply
- The maximum supply set for the token createdPreconditions:
[[eosio::action]]
void issue(const name& to, const asset& quantity, const string& memo);
Issues a specific quantity of tokens to an account.
Preconditions:
Parameters:
to
- The account to issue tokens to (must be the same as the issuer)quantity
- The amount of tokens to be issuedmemo
- The memo string that accompanies the token issue transaction[[eosio::action]]
void retire(const asset& quantity, const string& memo);
Effectively burns the specified quantity of tokens, removing them from circulation. Only the token issuer can retire tokens.
Parameters:
quantity
- The quantity of tokens to retirememo
- The memo string to accompany the transaction[[eosio::action]]
void transfer(const name& from, const name& to, const asset& quantity, const string& memo);
Transfers a specified quantity of tokens from one account to another.
Parameters:
from
- The account to transfer fromto
- The account to be transferred toquantity
- The quantity of tokens to be transferredmemo
- The memo string to accompany the transaction[[eosio::action]]
void open(const name& owner, const symbol& symbol, const name& ram_payer);
Each account's balance is a row in a table, which costs 240 bytes of RAM. This action creates a row in the table for the owner account and token symbol. If this is not done, then the first sender of a token to an account that does not have tokens will pay the RAM cost of creating the row.
Parameters:
owner
- The account to be createdsymbol
- The token to be paid with by ram_payerram_payer
- The account that supports the cost of this actionAdditional information can be found in issue #62 and issue #61.
[[eosio::action]]
void close(const name& owner, const symbol& symbol);
This action is the opposite of open. It closes the row for an account for a specific token symbol and reclaims the RAM.
Parameters:
owner
- The owner account to execute the close action forsymbol
- The symbol of the token to execute the close action forPreconditions:
struct [[eosio::table]] account {
asset balance;
uint64_t primary_key() const { return balance.symbol.code().raw(); }
};
The account
struct represents an individual token account and stores the balance for a specific token symbol.
typedef eosio::multi_index<"accounts"_n, account> accounts;
The accounts
table stores token balances for all accounts.
accounts
Usage:
For example try fetch GFL balance
import {APIClient} from "@wharfkit/session"
const client = new APIClient({ url: Chains.GlobalForce.url });
const result = await client.v1.chain.get_table_rows({
json: true,
code: 'eosio.token',
scope: 'SOME_ACCOUNT_HERE',
table: 'accounts',
});
/*
{
rows: [
{
balance: "100.0000 GFL",
}
],
more: false,
}
*/
struct [[eosio::table]] currency_stats {
asset supply;
asset max_supply;
name issuer;
uint64_t primary_key() const { return supply.symbol.code().raw(); }
};
The currency_stats
struct stores information about a token.
Fields:
supply
- The current supply of the token in circulationmax_supply
- The maximum possible supply of the tokenissuer
- The account name of the token issuer who has authority to issue new tokenstypedef eosio::multi_index<"stat"_n, currency_stats> stats;
The stats
table stores information about each token type.
stat
Usage:
For example try fetch GFL stat
import {APIClient} from "@wharfkit/session"
const client = new APIClient({ url: Chains.GlobalForce.url });
const result = await client.v1.chain.get_table_rows({
json: true,
code: 'eosio.token',
scope: 'GFL',
table: 'stat',
});
/*
{
rows: [
{
supply: "2100000000.0000 GFL",
max_supply: "2100000000.0000 GFL",
issuer: "eosio.token",
}
],
more: false,
}
*/
GFL token standard is a set of rules that all tokens on a blockchain must follow. This allows for interoperability between different tokens and applications. {%