There are multiple different implementations of the Dfinity token (Fungible Token and Non-Fungible Token) standards and no consensus can be formed. This will be detrimental to the development of Defi on IC network.
IC Canister’s methods are not allowed polymorphism, which creates a barrier to token compatibility.
Is it possible to form a specification for different standards to be compatible with each other and achieve compatibility without intrusion?
I’m thinking about an idea and working on some examples.
Idea:
main interface implements a standard scheme using the method names of ERC20. The optional compatibility interface implements self/other standard schemes with the method names plus the standard name prefix xxx_
.
standard method
Returns the list of supported token standards, in lowercase letters, separated by “;
”. The format is similar to “main standard; compatible standard 1; compatible standard 2
”. E.g. “dip20; drc20
”, “dft
”.
standard: () -> (text) query;
Main interface
Use the method names of ERC20 to define the main interface.
For example:
name: () -> (text) query;
symbol: () -> (text) query;
decimals: () -> (nat8) query;
totalSupply: () -> (nat) query;
balanceOf: (...) -> (...) query;
transfer: (...) -> (...);
transferFrom: (...) -> (...);
approve: (...) -> (...);
allowance: (...) -> (...);
...
Optional compatibility interface
Use the method names prefixed with standard name “xxx_” to define the compatibility interfaces.
For example 1:
dip20_name: () -> (text) query;
dip20_symbol: () -> (text) query;
dip20_decimals: () -> (nat8) query;
dip20_totalSupply: () -> (nat) query;
dip20_balanceOf: (...) -> (...) query;
dip20_transfer: (...) -> (...);
dip20_transferFrom: (...) -> (...);
dip20_approve: (...) -> (...);
dip20_allowance: (...) -> (...);
...
For example 2:
dft_name: () -> (text) query;
dft_symbol: () -> (text) query;
dft_decimals: () -> (nat8) query;
dft_totalSupply: () -> (nat) query;
dft_balanceOf: (...) -> (...) query;
dft_transfer: (...) -> (...);
dft_transferFrom: (...) -> (...);
dft_approve: (...) -> (...);
dft_allowance: (...) -> (...);
...
Single-standard compatibility example
standard: () -> (text) query; // “drc20”
// drc20
name: () -> (text) query;
symbol: () -> (text) query;
decimals: () -> (nat8) query;
totalSupply: () -> (nat) query;
balanceOf: (...) -> (...) query;
transfer: (...) -> (...);
transferFrom: (...) -> (...);
approve: (...) -> (...);
allowance: (...) -> (...);
...
// drc20 (Compatibility aliases)
drc20_name: () -> (text) query;
drc20_symbol: () -> (text) query;
drc20_decimals: () -> (nat8) query;
drc20_totalSupply: () -> (nat) query;
drc20_balanceOf: (...) -> (...) query;
drc20_transfer: (...) -> (...);
drc20_transferFrom: (...) -> (...);
drc20_approve: (...) -> (...);
drc20_allowance: (...) -> (...);
...
Multi-standard compatibility example
standard: () -> (text) query; // “dft; drc20”
// dft
name: () -> (text) query;
symbol: () -> (text) query;
decimals: () -> (nat8) query;
totalSupply: () -> (nat) query;
balanceOf: (...) -> (...) query;
transfer: (...) -> (...);
transferFrom: (...) -> (...);
approve: (...) -> (...);
allowance: (...) -> (...);
...
// drc20
drc20_name: () -> (text) query;
drc20_symbol: () -> (text) query;
drc20_decimals: () -> (nat8) query;
drc20_totalSupply: () -> (nat) query;
drc20_balanceOf: (...) -> (...) query;
drc20_transfer: (...) -> (...);
drc20_transferFrom: (...) -> (...);
drc20_approve: (...) -> (...);
drc20_allowance: (...) -> (...);
...
Standard List.
(Welcome to add new token standards!)
Fungible Token
- dip20: GitHub - Psychedelic/DIP20: DIP20: A fungible token standard for the DFINITY Internet Computer.
- dft: GitHub - Deland-Labs/dfinity-fungible-token-standard: Dfinity's fungible token standard. Any PRs and comments are welcome,collaborate with us to build this standard
- drc20: DRC_standards/DRC20 at main · iclighthouse/DRC_standards · GitHub
- ext: GitHub - Toniq-Labs/extendable-token
- motokotoken: GitHub - enzoh/motoko-token: The Token Package
- is20: GitHub - infinity-swap/IS20