-
Notifications
You must be signed in to change notification settings - Fork 137
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
[Discussion] Native fungible token #102
Comments
Addressing comment from @evgenykuzyakov :
For accounts that do not use fungible token there should not be extra overhead. Is there a specific design you are thinking of where this overhead is going to be palpable?
Contract calls require spinning up a virtual machine. Spinning up a VM will always have extra cost and probably theoretical limits on how fast it can be. @olonho are you aware of any instance of VM that takes almost no CPU cost to spin up? |
Overhead for protocol tokens:
AlternativeRequirements:
ModulesModule is identified by Modules allow implementation of large number of use-cases that require p2p operations without touching the centralized contract. E.g. transfers Example of a token module
The contract call can check permissions, subtract balance and make a call to the same module but on on Now when implementing a module contract you have 2 additional fields in the context:
Based on the To have a refund in case the transfer fails (e.g. because |
@evgenykuzyakov where is user data stored? Is it also globally available? |
Since there can be Modules themselves are added as a persistent map to the account similar to access keys. They are stored as /// (KEY)
TrieKey::Module {
account_id: AccountId,
module_id: ModuleId,
}
/// (VALUE) Optional to have, but it can have module permissions later.
/// E.g. whether the module can spend native tokens.
Module {
code_hash: CryptoHash
} The module stores data under: (KEY)
TrieKey::ModuleData {
account_id: AccountId,
module_id: ModuleId,
data_key: Vec<u8>,
}
/// (VALUE)
Vec<u8>
` |
I see. That makes sense. What about some metadata of the module itself? For example if it is a fungible token module, people may want to know about the total supply. |
My idea is to store global logic/data on the centralized account, e.g. "token-module". It will have the same contract, but it allows to mint/burn tokens. If it's a multi-token contract then it can also have a registry for tokens names and distribute initial supply |
We are considering adding a native fungible token support on the runtime level. On the low-level each account record will have a map
id of the token -> balance
which will be empty by the default and the runtime will operate with it exactly the same way it operates with NEAR token: it will perform balance checks and use the same transactions actions to operate with it. The benefit of it, is that we can have significantly faster and cheaper fungible token operations, and very strong safety guarantees (as oppose to people relying on the safety of various fungible token implementations).As a bonus feature, we might be able to re-express state staking and validator staking as transfer operations in terms of these account records, as three different tokens that are tied 1:1 with each other.
This issue does not provide thorough description of the proposed design, since the purpose is to open the discussion of the potential design, pros/cons, and the timeline.
Please leave the comments.
The text was updated successfully, but these errors were encountered: