GithubHelp home page GithubHelp logo

receronp / icrc23 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from natlabs/icrc1

0.0 0.0 0.0 209 KB

A full implementation of the ICRC fungible token standards

Home Page: https://natlabs.github.io/icrc1

License: MIT License

Makefile 0.87% Dhall 1.22% Motoko 97.91%

icrc23's Introduction

ICRC-1 Implementation

This repo contains the implementation of the ICRC-1 token standard.

References and other implementations

Documentation

Getting Started

  • Expose the ICRC-1 token functions from your canister

    • Import the icrc1 lib and expose them in an actor class.

      Take a look at the examples

  • Launch the basic token with all the standard functions for ICRC-1

    • Install the mops package manager
    • Replace the values enclosed in < > with your desired values and run in the terminal
      git clone https://github.com/NatLabs/icrc1
      cd icrc1
      mops install
      dfx start --background --clean
    
      dfx deploy icrc1 --argument '( record {                     
          name = "<Insert Token Name>";                         
          symbol = "<Insert Symbol>";                           
          decimals = 6;                                           
          fee = 1_000_000;                                        
          max_supply = 1_000_000_000_000;                         
          initial_balances = vec {                                
              record {                                            
                  record {                                        
                      owner = principal "<Insert Principal>";   
                      subaccount = null;                          
                  };                                              
                  100_000_000                                 
              }                                                   
          };                                                      
          min_burn_amount = 10_000;                         
          minting_account = null;                                 
          advanced_settings = null;                               
      })'
  • Create a token dynamically from a canister

        import Nat8 "mo:base/Nat8";
        import Token "mo:icrc1/ICRC1/Canisters/Token";
    
        actor{
            let decimals = 8; // replace with your chosen number of decimals
    
            func add_decimals(n: Nat): Nat{
                n * 10 ** decimals
            };
    
            let pre_mint_account = {
                owner = Principal.fromText("<Insert Principal>");
                subaccount = null;
            };
    
            let token_canister = Token.Token({
                name = "<Insert Token Name>";
                symbol = "<Insert Token Symbol>";
                decimals = Nat8.fromNat(decimals);
                fee = add_decimals(1);
                max_supply = add_decimals(1_000_000);
    
                // pre-mint 100,000 tokens for the account
                initial_balances = [(pre_mint_account, add_decimals(100_000))]; 
    
                min_burn_amount = add_decimals(10);
                minting_account = null; // defaults to the canister id of the caller
                advanced_settings = null; 
            });
        }

The fields for the advanced_settings record are documented here

Textual Representation of the ICRC-1 Accounts

This library implements the Textual Representation format for accounts defined by the standard. It utilizes this implementation to encode each account into a sequence of bytes for improved hashing and comparison. To help with this process, the library provides functions in the ICRC1/Account module for encoding, decoding, converting from text, and converting to text.

Tests

Internal Tests

  • Download and Install vessel
  • Run make test
  • Run make actor-test
  • Install Rust and Cargo via rustup
    curl https://sh.rustup.rs -sSf | sh
  • Then run the ref-test command
    make ref-test

Funding

This library was initially incentivized by ICDevs. You can view more about the bounty on the forum or website. The bounty was funded by The ICDevs.org community and the DFINITY Foundation and the award was paid to @NatLabs. If you use this library and gain value from it, please consider a donation to ICDevs.

icrc23's People

Contributors

tomijaga avatar skilesare 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.