Token Standard

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 %}

Actions

create

[[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:

Preconditions:

issue

[[eosio::action]]
void issue(const name& to, const asset& quantity, const string& memo);

Issues a specific quantity of tokens to an account.

Preconditions:

Parameters:

retire

[[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:

transfer

[[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:

open

[[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:

Additional information can be found in issue #62 and issue #61.

close

[[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:

Preconditions:

Tables

Account data structure

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.

Usage:

Fetching balances using Wharfkit

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,
}
 */

currency_stats

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:

typedef eosio::multi_index<"stat"_n, currency_stats> stats;

The stats table stores information about each token type.

Usage:

Fetching stats using Wharfkit

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,
}

 */

Token Standard

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. {%

Loading...