GithubHelp home page GithubHelp logo

dougbutner / antools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from currentxchange/ant-token-standard

0.0 0.0 0.0 110 KB

πŸœπŸ›  Tools and Token Standards for Antelope Blockchains (WAX, Telos, EOS, UX, Proton)

License: MIT License

C++ 100.00%

antools's Introduction

ANT Token Standard

The ANT (Antelope) Token Standards is an unofficial token contract that seeks to replace the EOSIO.token contract on WAX, Telos, EOS + UX blockchains, and anyone else using Antelope. I've nicknamed the collection of standards ANT as it's the beginning of Antelope and after ANTioquΓ­a, Colombia, and ants.

This standard, by default, provides features such as token transfers, many tokens per contract, token symbols unique to the contract, control over the RAM payer, the ability to close accounts (delete rows) with zero balance (new), and, of course, the process for creating and issuing tokens. The base implementation is split into a .cpp file (token.cpp) and a header file (token.hpp), and additional standards follow the same format with different file names.

Here's more information about the eosio.token standard this is based on.

This standard, by default, provides features such as token transfers, many tokens per contract, token symbols unique to the contract, control over the RAM payer, the ability to close accounts (delete rows) with zero balance, and, of course, the process for creating and issuing tokens. The base implementation is split into a .cpp file (token.cpp) and a header file (token.hpp), and additional standards follow the same format with different file names.

Here's more information about the eosio.token standard this is based on.

Features

  • Fork of eosio.token contract
  • Control over freeing RAM given to contract
    This is a change from the eosio.token standard, previously only token owner with blank balance could clear their row. This feature was added so that a contract has the ability to maintain a more accurate list of holders.
  • Contract + owner can close accounts with zero balance, freeing up RAM
    • Be aware this means the token may dissapear from the wallet in user interfaces + next transfer will require RAM to be paid again
  • More explicit error messages for easier debugging
  • Differences in the authorization process for creating and issuing tokens

Changes from eosio.token

  • Ability to delete rows has been given to contract in addition to the token holder, allowing your contract to free up RAM for users.

Basic Token for EOS, WAX, Telos, etc

  • Find the slightly-upgraded token contract as src/token/token.cpp and src/token/token.hpp

Token Standard Overview

Actions

  • create: Creates a new token with a specified issuer and maximum supply
  • issue: Issues a specified quantity of tokens to the issuer account with an optional memo
  • retire: Retires a specified quantity of tokens, reducing the supply with an optional memo
  • transfer: Transfers a specified quantity of tokens from one account to another with an optional memo
  • open: Opens a balance row for an account with zero balance for a specified symbol, with the specified RAM payer
  • close: Closes a balance row for an account with zero balance for a specified symbol

Data Structures

The ANT Token Standard uses two data structures: account and currency_stats. These data structures are stored in multi-index tables called accounts and stats, respectively.

Account

The account structure represents a token balance for a specific account. It contains a single member:

  • balance: An eosio::asset representing the balance of tokens held by the account. The primary_key() function for the account structure returns the raw symbol code of the balance, making each balance row unique within the accounts table.
struct [[eosio::table]] account {
    eosio::asset balance;
    uint64_t primary_key()const { return balance.symbol.code().raw(); }
};

Currency Stats

The currency_stats structure holds information about a specific token, such as its current supply, maximum supply, and the issuer. It contains the following members:

  • supply: An eosio::asset representing the current supply of the token.
  • max_supply: An eosio::asset representing the maximum supply of the token that can be issued.
  • issuer: An eosio::name representing the account that is allowed to issue and retire the token.
struct [[eosio::table]] currency_stats {
    eosio::asset supply;
    eosio::asset max_supply;
    eosio::name issuer;
    uint64_t primary_key()const { return supply.symbol.code().raw(); }
};

These data structures are used to store information about the token balances and token metadata. They are managed using the eosio::multi_index class, which enables the efficient querying and modification of the data stored in the multi-index tables. The accounts and stats tables are instances of the eosio::multi_index class, with the respective account and currency_stats structures as template arguments:

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

How to Build and Deploy

Prerequisites

  • EOSIO software installed
  • EOSIO or Antelope cdt (Contract Development Toolkit) installed
  • An EOSIO / Antelope account with enough resources (RAM, CPU, and NET) to deploy contract.

Steps

  1. Compile the contract: Using EOSIO cdt
eosio-cpp -l eosio -o src/token/deploy/token.wasm src/token/token.cpp --abigen --contract token

Using Antelope cdt

cdt-cpp -l eosio -o src/token/deploy/token.wasm src/token/token.cpp --abigen --contract token
  1. Deploy the contract to the EOSIO blockchain:
cleos set contract <your_account_name> <path_to_contract_directory> token.wasm token.abi

Replace <your_account_name> with your EOSIO account name and <path_to_contract_directory> with the path to the directory containing the compiled contract files (ant_token.wasm and ant_token.abi).

  1. Create a new token:
cleos push action <your_account_name> create '["<issuer_account_name>", "1000000000.0000 ANT"]' -p <your_account_name>

Replace <your_account_name> with your EOSIO account name and <issuer_account_name> with the desired issuer account name for the ANT token.

  1. Issue tokens to the issuer account:
cleos push action <your_account_name> issue '["<issuer_account_name>", "1000.0000 ANT", "Initial issuance"]' -p <issuer_account_name>

Replace <your_account_name> with your EOSIO account name and <issuer_account_name> with the issuer account name for the ANT token.

Now, the ANT token is ready to use. You can perform actions like transfer, retire, open, and close as needed.

License

This project is a fork from Antelope and is licensed under their original MIT License and additionally licensed under the [MIT License](LICENSE changes) by Current X Change LLC where applicable.

Disclaimer of Liability

Please read this Disclaimer of Liability carefully before using any smart contracts located at https://github.com/currentxchange/ANT-token-standard (the "Contracts").

The Contracts are provided on an "as is" basis. Neither Douglas Butner, the original authors, Current X Change LLC, nor any other parties associated with the development and maintenance of the Contracts make any warranties or representations, express or implied, as to the suitability, completeness, quality, appropriateness, or operation of the Contracts.

The Contracts have not been audited for security vulnerabilities. As such, use of the Contracts is at your own risk. You are solely responsible for any damage, liability, or loss that you may incur as a result of or in connection with your use of the Contracts. You should make sure you understand the workings and intricacies of blockchain technologies before using the Contracts.

The Contracts contain code that has been ported from other repositories. It is your responsibility to respect any and all applicable licenses attached to that code. You must review these licenses and ensure that your use of the Contracts does not violate them.

By using the Contracts, you agree to this Disclaimer of Liability, and you waive any right to hold Douglas Butner, the original authors, Current X Change LLC, or any other parties associated with the Contracts liable for any damage, liability, or loss that you may incur in connection with your use of the Contracts.

YOUR USE OF THE CONTRACTS INCLUDING MODIFICATION AND USE CONSTITUTES YOUR AGREEMENT TO THIS DISCLAIMER OF LIABILITY.

antools's People

Contributors

dougbutner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.