-
Notifications
You must be signed in to change notification settings - Fork 138
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
Multi fungible token #228
Multi fungible token #228
Conversation
Good job writing this up! |
I'm curious why this was considered useful. What does it mean to have "the same behavior" as NEP-141? Does every MFT contract need to have a "default token"? To me it seems like, for contracts that DO want to have a "default token", they could implement the FT interface as well. the |
Do you think Multi-Fungible Token would be necessary if we had a more general Multi-Token Standard similar to ERC-1155? |
I think it's the same, except the |
@marco-sundsk Please, help me understand whether this PR is still relevant given #245 was merged. |
I think this PR should be closed. |
@marco-sundsk Thank you for your contribution! 🚀 |
Summary
A standard interface for multi fungible tokens that allows for a normal transfer as well as a transfer and method call in a single transaction. The storage standard and the fungible token metadata standard are the same with NEP-141.
Motivation
There are many needs that request to handle more than one token in a single NEAR contract. For example, Ref Finance handles their all swap pools in one contract, and release LP tokens for each pool. Those tokens are all different fungible tokens which exist in a single contract. it can NOT be supported by NEP-141 standard directly.
Someone may argue why not we split those tokens into different contracts? There are several reasons for this choice:
This proposal will address that problem. With our MFT protocol, users and developers can organize multiple tokens in one contract, and has them having all the abilities that NEP-141 can do.
Prior art:
Guide-level explanation
MFT is an abbreviation for Multple Fungilbe Token. On NEAR network, it means using one single contract to manage mulitple fungible tokens, and those tokens are very likely to have similar logic, purpose or in same category.
To understand this standard, you should first read NEP-141 guide-level explanation.
The difference here is we add a special field
token_id
into those interfaces to enable distinguish tokens in the multi-fungible-token contract. Generally speaking, when the value of this field equals to predecessor_id or the token contract id, the interface has the same behaviors with original one in NEP-141. Otherwise, the token_id stands for an internal index in that MFT contract.The example scenarios is just the same with NEP-141, only need remember to add that special field as the first argument for following interface:
mft_resolve_transfer
in trait MFTTokenResolvermft_on_transfer
in trait MFTTokenReceivermft_transfer
mft_transfer_call
mft_metadata
, return the same FungibleTokenMetadata structure in NEP-141mft_register
mft_total_supply
mft_balance_of
Reference-level explanation
NOTES:
Interface:
we only list those are different with NEP-141
The following behavior is required, but contract authors may name this function something other than the conventional mft_resolve_transfer used here.
Drawbacks
token_id
argument is freeform, which may necessitate conventions.Future possibilities