DIP20: A fungible token standard for the DFINITY Internet Computer.

Related tags

Utilities DIP20
Overview

Group 5981 (1)

DIP20 - Introduction

Token standards are essential for the Internet Computer ecosystem, especially for the decentralized finance ecosystem (DeFi) system. In this token interface, we implemented an ERC-20 style token standard in both Motoko and Rust, the standard is named DIP20.

This standard allows for a common and familiar interface that not only provides a quick entry point for existing blockchain developers, but future interoperability options between the Internet Computer and Ethereum, through the process of sustaining the same shared interfaces.

You can find the interface descriptions in the specification file.

This branch contains code of several other token canister templates.

Development

You need the latest DFINITY Canister SDK to be able to build and deploy a token canister:

sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

Navigate to a the sub directory and start a local development network:

cd motoko
dfx start --background

Create canisters:

dfx canister create --all

Install code for token canister:

dfx build

dfx canister install token --argument="(\"<NAME>\", \"<SYMBOL>\", <DECIMALS>, <TOTAL_SUPPLY>, <YOUR_PRINCIPAL_ID>)"
e.g.:
dfx canister install token --argument="(\"DFinance Coin\", \"DFC\", 8, 10000000000000000, principal \"4qehi-lqyo6-afz4c-hwqwo-lubfi-4evgk-5vrn5-rldx2-lheha-xs7a4-gae\")"

Refer to demo.sh in the corresponding sub directory for more details.

Contributing

We'd like to collaborate with the community to provide better token standard implementation for the developers on the IC, if you have some ideas you'd like to discuss, submit an issue, if you want to improve the code or you made a different implementation, make a pull request!

Comments
  • During canister install token : Invalid data: Unable to serialize Candid values: wrong number of argument values

    During canister install token : Invalid data: Unable to serialize Candid values: wrong number of argument values

    While trying to run the create token commands, this error shows up.

    Way to Replicate Error: cd rust dfx canister create --all dfx build dfx canister install token --argument="("data:image/jpeg;base64,...", "DFinance Coin", "DFC", 8, 10000000000000000, principal "qk36l-k7g7k-mtr6a-bfuek-eqsah-yjjj7-jurfe-54jjj7-jurfe-554sq-d7qhw-jw3su-jqe", 10000)" Invalid data: Unable to serialize Candid values: wrong number of argument values

    opened by harshnambiar 2
  • feat: tooling, guard methods, organization

    feat: tooling, guard methods, organization

    feat: adds tooling (cap autosetup, healthcheck, deploy scripts) fix: random character in license fix: updated information segment in main.rs refractor: restructure rust folder (it can now be used within another project with no issues from cargo as well) feat: guard methods for permissioned calls fix: issue with transfers trapping

    opened by ozwaldorf 1
  • Support for passing in a custom string in `Other` TxError

    Support for passing in a custom string in `Other` TxError

    This will extend the usage of the enum type TxError::Other to support arbitrary strings. This will help in surfacing errors coming from cap or anything else.

    Ex:

    TxError::Other(format!(
                "Inserting into cap failed with error: {:?}",
                error
            ))
    
    opened by b0xtch 1
  • chore: pass caller to add_record on every call

    chore: pass caller to add_record on every call

    • add_record used an Option on caller, cap_sdk expects a value for the param caller.

    • https://github.com/Psychedelic/cap/blob/85d135eb43433adef9b6681260ce64eaa5dbe48c/sdk/standards/src/dip20/cap.rs#L587

    • refer to link above.

    • if None is passed this will throw

    image

    opened by b0xtch 0
  • dip20 fails cargo audit with RUSTSEC-2022-0013 and RUSTSEC-2021-0127

    dip20 fails cargo audit with RUSTSEC-2022-0013 and RUSTSEC-2021-0127

    issue: 1 warn and 1 vuln, looks like cpu dos

    command output:

    (ins)kod@m1:~/code/DIP20/rust$ cargo audit
        Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
          Loaded 417 security advisories (from /Users/kod/.cargo/advisory-db)
        Updating crates.io index
        Scanning Cargo.lock for vulnerabilities (164 crate dependencies)
    Crate:     regex
    Version:   1.5.4
    Title:     Regexes with large repetitions on empty sub-expressions take a very long time to parse
    Date:      2022-03-08
    ID:        RUSTSEC-2022-0013
    URL:       https://rustsec.org/advisories/RUSTSEC-2022-0013
    Solution:  Upgrade to >=1.5.5
    Dependency tree:
    regex 1.5.4
    ├── lalrpop-util 0.19.7
    │   ├── lalrpop 0.19.7
    │   │   └── candid 0.7.11
    │   │       ├── token 0.1.0
    │   │       ├── ic-cdk-macros 0.3.3
    │   │       │   ├── token 0.1.0
    │   │       │   └── ic-kit 0.4.3
    │   │       │       ├── token 0.1.0
    │   │       │       ├── cap-sdk-core 0.1.0-alpha1
    │   │       │       │   └── cap-sdk 0.1.0-alpha1
    │   │       │       │       ├── token 0.1.0
    │   │       │       │       └── cap-standards 0.1.0-alpha1
    │   │       │       │           └── token 0.1.0
    │   │       │       ├── cap-sdk 0.1.0-alpha1
    │   │       │       └── cap-common 0.1.0
    │   │       │           └── cap-sdk-core 0.1.0-alpha1
    │   │       ├── ic-cdk 0.3.3
    │   │       │   ├── token 0.1.0
    │   │       │   ├── ic-kit 0.4.3
    │   │       │   ├── ic-cdk-macros 0.3.3
    │   │       │   ├── cap-standards 0.1.0-alpha1
    │   │       │   ├── cap-sdk-core 0.1.0-alpha1
    │   │       │   ├── cap-sdk 0.1.0-alpha1
    │   │       │   └── cap-common 0.1.0
    │   │       └── cap-standards 0.1.0-alpha1
    │   └── candid 0.7.11
    └── lalrpop 0.19.7
    
    Crate:     serde_cbor
    Version:   0.11.2
    Warning:   unmaintained
    Title:     serde_cbor is unmaintained
    Date:      2021-08-15
    ID:        RUSTSEC-2021-0127
    URL:       https://rustsec.org/advisories/RUSTSEC-2021-0127
    Dependency tree:
    serde_cbor 0.11.2
    └── cap-common 0.1.0
        └── cap-sdk-core 0.1.0-alpha1
            └── cap-sdk 0.1.0-alpha1
                ├── token 0.1.0
                └── cap-standards 0.1.0-alpha1
                    └── token 0.1.0
    
    error: 1 vulnerability found!
    warning: 1 allowed warning found
    

    suggested action:

    cargo update
    
    opened by kernelzeroday 0
  • WIP Proposal: flusher logic for tx_log using heartbeat

    WIP Proposal: flusher logic for tx_log using heartbeat

    This might be nice to have if we have multiple failed transactions in the cap queue.

    A heartbeat increases the cost of running a canister so maybe we can put this on the back burner or as an extension module.

    question wip 
    opened by b0xtch 0
  • IC CDK Storage bug

    IC CDK Storage bug

    Any code that uses the IC CDK storage is using unsafe Rust which can result in race conditions. This may not introduce downstream issues in your code, but it was a problem for us, and certainly may be a problem if storage is used more widely throughout the codebase.

    opened by blutooth 2
  • Changing Fees - Issue

    Changing Fees - Issue

    The caller of the transfer method can't reliably predict the fee amount that will be charged when transferring out. After a query call has been made to retrieve the fee value and before the actual transfer call, it's possible the fee could be changed by the owner. This may be a rare occurrence but can cause issues for downstream applications who may send more tokens than is necessary if a fee is changed by the owner.

    Two possible fixes include making the transfer method have a limit parameter to ensure that fee + transfer value <= limit, or changing the transfer function so that the amount transferred is inclusive rather than exclusive of the fee.

    opened by blutooth 1
  • rust example build failed

    rust example build failed

    error[E0308]: mismatched types
       --> src/main.rs:537:13
        |
    537 |             caller,
        |             ^^^^^^
        |             |
        |             expected enum `std::option::Option`, found struct `candid::Principal`
        |             help: try using a variant of the expected enum: `_::_serde::__private::Some(caller)`
        |
        = note: expected enum `std::option::Option<candid::Principal>`
                 found struct `candid::Principal`
    
    For more information about this error, try `rustc --explain E0308`.
    error: could not compile `token` due to previous error
    
    ben@u2 ~/D/rust (main) [101]> rustc --version
    rustc 1.57.0 (f1edd0429 2021-11-29)
    
    opened by jim3333 2
Owner
Psychedelic
Decentralized product studio focused on building products on Web3, Ethereum, and the Internet Computer.
Psychedelic
Sol Batch Token Transfer CSV

Sol Batch Token Transfer CSV This script can batch transfer any SPL token to multiple addresses listed in a CSV, and then save the tx hash to a new CS

The Z Institute 10 Nov 6, 2022
A fork of 'discord-token-botter' for rust lang.

Shahzain Botter V3(Rust) - If you were sold this tool, you have been scammed, this tool is free & open source Please DO NOT pay money for this tool A

Shahzain 5 Nov 7, 2022
A merkle-based token distributor for the Solana network that allows distributing a combination of unlocked and linearly unlocked tokens.

merkle-distributor A program for distributing tokens efficiently via uploading a Merkle root. Claiming Airdrop via CLI To claim via CLI instead of usi

null 6 Dec 8, 2023
Token management program (vesting and mining) implemented in Anchor

Deep Dive into Anchor by Implementing Token Management Program Author: @ironaddicteddog, @emersonliuuu [Updated at 2022.5.21] You can find the full co

Something-Something 8 Aug 12, 2024
Czkawka is a simple, fast and easy to use app to remove unnecessary files from your computer.

Multi functional app to find duplicates, empty folders, similar images etc.

Rafał Mikrut 9.2k Jan 4, 2023
This is an implementation defining standard for client-side-validation

Client-side-validation Foundation Libraries This is an implementation defining standard of client-side-validation representing a set of its Foundation

LNP/BP Association 8 Dec 3, 2022
A small tool to clone git repositories to a standard location, organised by domain name and path.

A small tool to clone git repositories to a standard location, organised by domain name and path. Runs on BSD, Linux, macOS, Windows, and more.

Wesley Moore 68 Dec 19, 2022
Dfinity's fungible token standard. Any PRs and comments are welcome,collaborate with us to build this standard

Dfinity's fungible token standard. Any PRs and comments are welcome,collaborate with us to build this standard

Deland Labs 46 Nov 7, 2022
DIP721 - An Internet Computer Non-fungible Token Standard

DIP721 - Introduction DIP721 is an ERC-721 style non-fungible token standard built mirroring its Ethereum counterpart and adapting it to the Internet

Psychedelic 48 Nov 24, 2022
Dank - The Internet Computer Decentralized Bank - A collection of Open Internet Services - Including the Cycles Token (XTC)

Dank - The Internet Computer Decentralized Bank Dank is a collection of Open Internet Services for users and developers on the Internet Computer. In t

Psychedelic 56 Nov 12, 2022
Open Internet Service to store transaction history for NFTs/Tokens on the Internet Computer

CAP - Certified Asset Provenance Transaction history & asset provenance for NFT’s & Tokens on the Internet Computer CAP is an open internet service pr

Psychedelic 42 Nov 10, 2022
Cover is an open internet service for canister code verification on the Internet Computer

Cover Cover (short for Code Verification) is an open internet service that helps verify the code of canisters on the Internet Computer. Visit our webs

Psychedelic 14 Oct 31, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
NFT & Marketplace Contracts with royalties and fungible token support. Sample React app included.

NFT Market Reference Implementation A PoC backbone for NFT Marketplaces on NEAR Protocol. Reference Changelog Changelog Progress: basic purchase of NF

NEAR App Examples 156 Apr 28, 2022
Bespoke toolkit for Non-fungible token (NFT) technology 🚀

Bespoke toolkit for Non-fungible token (NFT) technology ?? What is Onft? Instead of forcing a consensus algorithm or peer networking on you, Onft prov

Owez 5 Jan 9, 2022
ARYA Network is a polkadot/substrate based chain for Non-fungible Token platform on which we can own sell and buy the NFT's on polkadot network.

ARYA Network ARYA Network is a polkadot/substrate based chain for Non-fungible Token platform on which we can own sell and buy the NFT's on polkadot n

Pankaj Chaudhary 6 Dec 20, 2022
An all-in-one IBC protocol providing fungible token transfer, interchain account, and async query functionalities

ICS-999 An all-in-one IBC protocol providing fungible token transfer, interchain account (ICA), and query (ICQ) functionalities, implemented in CosmWa

larry 9 Apr 1, 2023
A standard for fungible tokens on Move.

Move Program Kit (MPK) The Move Program Kit (MPK) is a collection of software written in the Move programming language for the Aptos blockchain. Modul

Menlo Labs 6 Jul 25, 2022
A lightweight standard for non-fungible assets.

Nifty Asset A lightweight standard for non-fungible assets. Contents Features Overview Packages Building Testing Programs Clients CLI License Warning

null 14 Mar 6, 2024
All the data an IC app needs to make seamless experiences, accessible directly on the IC. DAB is an open internet service for NFT, Token, Canister, and Dapp registries.

DAB ?? Overview An Internet Computer open internet service for data. All the data an IC app needs to make a seamless experience, accessible directly o

Psychedelic 58 Oct 6, 2022