Building an ICRC-1,2,3,4, and 10 Fungible Token Series

I’ll try to keep this topic up to date as well as answer questions. I hope it is helpful for someone:

Part 1:

We launch an ICRC 1, 2, 3, 4, and 10 compatible token on Internet Computer.

Things you will need:
git - Git - Installing Git
dfx - support.dfinity.org/hc/en-us/articles/10552713577364-How-do-I-install-dfx
mops - mops.one/
motoko vs code extension - Motoko - Visual Studio Marketplace
fork icrc_fungible - GitHub - PanIndustrial-Org/ICRC_fungible: A full implementation of an ICRC 1,2,3 compatible fungible token
get a canister - nns.ic0.app/ (You will need a couple ICP)

9 Likes

Part 2:

In this video we:

  • Set up your local Internet Computer Replica to run NNS canisters including a fake ICP Ledger.
  • Send our selves fake ICP
  • Write code that let’s us mint ICDevs tokens from ICP
  • Write code that lets ICDevs withdraw ICP to the ICDevs Neuron that funds our charity.

Code at the start: Video 1 · icdevsorg/ICDevsToken@e8bc2d7 · GitHub

Code at the end: Video 2 · icdevsorg/ICDevsToken@b80cc88 · GitHub

ICScan for .did file of Ledger: icscan.io/canister/ryjl3-tyaaa-aaaaa-aaaba-cai

dfx nns extension information: sdk/docs/cli-reference/dfx-nns.mdx at master · dfinity/sdk · GitHub

Calista for converting Principals to account ids: k7gat-daaaa-aaaae-qaahq-cai.raw.ic0.app/docs/

The ICDevs Neuron: Neuron: ICDevs.org - ICP Dashboard

To Mint $ICDevs

Access the ICP Ledger from Candid UI: DFINITY Canister Candid UI

Step 1. Log in.
Step 2. Send ICP to the principal you are assigned
Step 3. Call icrc2_approve with an amount in e8s ( 1ICP = 100000000 - a one and 8 zeros . Minimum is 1000000 e8s) and the spender owner of agtsn-xyaaa-aaaag-ak3kq-cai

Access the $ICDevs ledger from Candid UI: DFINITY Canister Candid UI

Step 1. Log in
Step 2. Call MintFromICP with the same amount you approved and set your target to a plug wallet principal(recommended). Do not set your nns.ic0.app principal as a target or you will not be able get to your tokens.

Steps in dfx(you must have ICP in your dfx account):

dfx canister --network ic call ryjl3-tyaaa-aaaaa-aaaba-cai icrc2_approve ‘(
record {
fee = opt (10_000 : nat);
memo = null;
from_subaccount = null;
created_at_time = null;
amount = 100_000_000 : nat;
expected_allowance = null;
expires_at = null;
spender = record {
owner = principal “agtsn-xyaaa-aaaag-ak3kq-cai”;
subaccount = null;
};
},
)’

dfx canister --network ic call agtsn-xyaaa-aaaag-ak3kq-cai mintFromICP ‘(
record {
source_subaccount = null;
target = opt record {
owner = principal “{your-plug-principal}”;
subaccount = null;
};
amount = 100_000_000 : nat;
},
)’

Add $ICDevs to your plug with canister ID agtsn-xyaaa-aaaag-ak3kq-cai and type ICRC1.

4 Likes

Hey @skilesare, when I go to Candid UI and click the login button, it takes me to https://identity.internetcomputer.org/#authorize which does not show my II’s. But, if I go to https://identity.ic0.app/#, my II’s are there. Is one of these login links deprecated, or should I be able to log in to Candid UI somehow using either one? Or are these two links totally unrelated to each other and used for different purposes? I’m a bit confused. Thanks in advance.

1 Like

Good question! I think both will get you the same II principal because they use the same mapping between number and domain for delegation, but I’d prefer that someone from DFINITY confirm. I think that @nmattia is/was on that team? (Sorry for the tag if not)

As a test you could log in on both and see if you get the same principal. In either case, only send enough ICP there that you want to use for the mint and you have a low downside. Or send a small amount first.

I’m obviously missing something because I don’t see how I can log in using the https://identity.ic0.app/#? I’m using Safari, and when I go to that link, my II’s show up without a problem. But then I copy/paste the link to the Candid UI, go there, and it says I have to log in. So, I click the login button at the top right of the Candid UI page, and it takes me to https://identity.internetcomputer.org/#authorize , which doesn’t show my II’s.

I realize it’s probably trivial to log into the II’s again on the other page, but it doesn’t sound like that’s necessary? I’m not seeing how I can use my II’s that are already set up at ic0.app instead of having to set them up again at internetcomputer.org though.

Huh…interesting…I just tried with my same number and it didn’t prompt for my key…unexpected. Let me see why this is the case. I also wonder who at dfinity is responsible for deploying candid ui. Maybe it hasn’t been updated in a while? Or maybe they want you to use that url now?

Edit: Ok…I can confirm that at some point they started using two different domains for safety:

I’d advise setting up keys at both domains in case one ever gets added to the black list again.

Awesome, thanks for digging into the history for me and finding an explanation! I’ll migrate over to the internetcomputer.org logins.

Hey @skilesare, I was able to successfully mint ICDevs tokens, but there was a small discrepancy in what I had to do vs your instructions.

I initially deposited 0.5 ICP or 50000000 in e8s. When I called the MintFromICP function using the same amount I approved, it gave me an error saying I had an insufficient balance and all that was available was 4999000. So, I just put that number in and it was successful. So when converting from one to the other, a transaction fee is subtracted. Not a big deal at all, but figured you may want to note it for future instructions. Hope it helps!

1 Like

Thank you! I’ll fidget with it. Once the app is up I’ll make the fees easier for the users to understand.

1 Like

In this video we do a deep dive into the ICRC-1 standard and the library we used to implement it for our $ICDV token.

More Info:

ICRC-1 Definition - ICRC-1/standards/ICRC-1/README.md at main · dfinity/ICRC-1 · GitHub
ICRC1.mo Library - icrc1.mo/src/ICRC1 at main · PanIndustrial-Org/icrc1.mo · GitHub
ICDV Token Repo - ICDevsToken/src at main · icdevsorg/ICDevsToken · GitHub
ICRC-10 - Supported Standards -github.com/skilesare/ICRC/tree/icrc61/ICRCs/ICRC-10
Motoko Migration Pattern - GitHub - ZhenyaUsenko/motoko-migrations: Sample project structure to implement migrations in motoko
Class+ Pattern - Writing Motoko stable libraries

I apologize for the strange dubbing at the end…my software stopped recording the screen for the second half and I had to improvise.

2 Likes

Part 4 - Let’s mint some ICDV

n this video we build a react widget that let’s us easily mint $ICDV from our ICDevs.org site.

Jekyll: jekyllrb.com/
Jen theme: jek | Jekyll Themes
The ICDevs Site: GitHub - icdevs/Icdevs_fleeksite
Vite-React-Motoko Starter Project: GitHub - rvanasa/vite-react-motoko: Starter project for Vite + React + TypeScript + Motoko
Terser Plugin: terser - npm
Download Plug Wallet: plugwallet.ooo/
Plug Documentation: docs.plugwallet.ooo/
Custom Domains on the IC: Using custom domains | Internet Computer
ic-reactor: ic-reactor

2 Likes