Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: icrc1_minting_account endpoint #29

Merged
merged 6 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ICRC-1.did
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Number of nanoseconds since the UNIX epoch in UTC timezone.
type Timestamp = nat64;

// Number of nanoseconds between two [Timestamp]service
// Number of nanoseconds between two [Timestamp]s.
type Duration = nat64;

type Subaccount = blob;
Expand Down Expand Up @@ -44,6 +44,7 @@ service : {
icrc1_decimals : () -> (nat8) query;
icrc1_fee : () -> (nat) query;
icrc1_total_supply : () -> (nat) query;
icrc1_minting_account : () -> (opt Account) query;
icrc1_balance_of : (Account) -> (nat) query;
icrc1_transfer : (TransferArgs) -> (variant { Ok: nat; Err: TransferError; });
icrc1_supported_standards : () -> (vec record { name : text; url : text }) query;
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ icrc1_metadata : () -> (vec record { text; Value }) query;

### icrc1_total_supply

Returns the total token supply.
Returns the total number of tokens on all accounts except for the [minting account](#minting_account).

```candid "Methods" +=
icrc1_total_supply : () -> (nat) query;
```

### icrc1_minting_account

Returns the [minting account](#minting_account) if this ledger supports minting and burning tokens.

```candid "Methods" +=
icrc1_minting_account : () -> (opt Account) query;
```

### icrc1_balance_of

Returns the balance of the account given as argument.
Expand Down Expand Up @@ -166,6 +174,23 @@ Namespace `icrc1` is reserved for keys defined in this standard.
| `icrc1:decimals` | `variant { Nat = 8 }` | The number of decimals the token uses. For example, 8 means to divide the token amount by 10<sup>8</sup> to get its user representation. When present, should be the same as the result of the [`icrc1_decimals`](#decimals_method) query call. |
| `icrc1:fee` | `variant { Nat = 10_000 }` | The default transfer fee. When present, should be the same as the result of the [`icrc1_fee`](#fee_method) query call. |

## Minting account <span id="minting_account"></span>

The minting account is a unique account that can create new tokens and acts as the receiver of burnt tokens.

Transfers _from_ the minting account act as _mint_ transactions depositing fresh tokens on the destination account.
Mint transactions have no fee.

Transfers _to_ the minting account act as _burn_ transactions, removing tokens from the token supply.
Burn transactions have no fee but might have minimal burn amount requirements.
If the client tries to burn an amount that is too small, the ledger SHOULD reply with

```
variant { Err = variant { BadBurn = record { min_burn_amount = ... } } }
```

The minting account is also the receiver of the fees burnt in regular transfers.

<!--
```candid ICRC-1.did +=
<<<Type definitions>>>
Expand Down
4 changes: 4 additions & 0 deletions ref/ICRC1.mo
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ actor class Ledger(init : {
totalSupply(log)
};

public query func icrc1_minting_account() : async ?Account {
?init.minting_account
};

public query func icrc1_name() : async Text {
init.token_name
};
Expand Down