# DRC20

[This standard](https://github.com/iclighthouse/DRC_standards/tree/main/DRC20) defines a fungible token interface suitable for interaction by both off-chain applications and on-chain smart contracts, addressing issues prevalent in IC network applications.

**Key Principles:**

* Maximize decentralization.
* Focus on core interfaces; leave out non-essential, specific functionalities.

**Improvements:**

* Account ID Compatibility: Aligns account identity using account-id, supporting `subaccount` and ensuring compatibility with `principal-id`.
* Pub/Sub Notification Model: Instead of dapps actively querying for events, this standard allows application canisters to subscribe to token canister messages using the subscribe() method. Missed messages can be retrieved with txnQuery().
* Transaction Record Storage: While Dfinity doesn't save transaction records like Ethereum, this standard recommends caching recent transactions in the token canister and using external canisters for historical data.
* Atomicity Enhancement with Lock/Execute Model: Addressing the non-atomicity of cross-canister transfers, methods like lockTransfer() and executeTransfer() ensure a two-phase transfer structure to improve atomicity.
* Preventing Duplicate Transactions: To counteract potential duplicate transactions and unclear transaction status due to network failures, the standard employs:
  * Nonce mechanism for transaction idempotency.
  * Pre-calculated txid using the DRC202 standard.
* Guarding Against Gas Attacks: Canister callers aren’t obligated to pay gas in the IC network. This standard adds a gas() method to estimate gas costs, leaving the setting of gas costs to developers.
* Tackling Malicious Approval Exploits: Adds the approvals() method allowing holders to review their approvals.
* Time-Weighted Balance: Introduces "CoinSeconds" – a time-weighted cumulative measure of account balance, aiding in calculating daily averages and balance ratios.
* Compatibility with other Token Standards: While DRC20 aligns with CTSNC, it also provides method aliases with a "drc20\_" prefix.

**Other Concerns:**

* Immutability and Decentralization: Emphasizes code immutability and equal rights with no special permissions. Canister management should be through governance canisters.
* Re-entrance Attack Prevention: Requires callers to pay gas, uses pub/sub for notifications, and updates state before external calls.
* Mint and Burn Methods: Suggests avoiding built-in mint() and burn() methods, leaving their inclusion to developers. The burn() method can utilize a specific blackhole address if required.807077e900000000000000000000000000000000000000000000000000000000(this's 0 address with checksum) can be used as the blackhole address.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://iclighthouse.gitbook.io/iclighthouse/products/drc-standards/drc20.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
