github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/supply/spec/01_concepts.md (about) 1 <!-- 2 order: 1 3 --> 4 5 # Concepts 6 7 ## Supply 8 9 The `supply` module: 10 11 - passively tracks the total supply of coins within a chain, 12 - provides a pattern for modules to hold/interact with `Coins`, and 13 - introduces the invariant check to verify a chain's total supply. 14 15 ### Total Supply 16 17 The total `Supply` of the network is equal to the sum of all coins from the 18 account. The total supply is updated every time a `Coin` is minted (eg: as part 19 of the inflation mechanism) or burned (eg: due to slashing or if a governance 20 proposal is vetoed). 21 22 ## Module Accounts 23 24 The supply module introduces a new type of `auth.Account` which can be used by 25 modules to allocate tokens and in special cases mint or burn tokens. At a base 26 level these module accounts are capable of sending/receiving tokens to and from 27 `auth.Account`s and other module accounts. This design replaces previous 28 alternative designs where, to hold tokens, modules would burn the incoming 29 tokens from the sender account, and then track those tokens internally. Later, 30 in order to send tokens, the module would need to effectively mint tokens 31 within a destination account. The new design removes duplicate logic between 32 modules to perform this accounting. 33 34 The `ModuleAccount` interface is defined as follows: 35 36 ```go 37 type ModuleAccount interface { 38 auth.Account // same methods as the Account interface 39 GetName() string // name of the module; used to obtain the address 40 GetPermissions() []string // permissions of module account 41 HasPermission(string) bool 42 } 43 ``` 44 45 > **WARNING!** 46 Any module or message handler that allows either direct or indirect sending of funds must explicitly guarantee those funds cannot be sent to module accounts (unless allowed). 47 48 The supply `Keeper` also introduces new wrapper functions for the auth `Keeper` 49 and the bank `Keeper` that are related to `ModuleAccount`s in order to be able 50 to: 51 52 - Get and set `ModuleAccount`s by providing the `Name`. 53 - Send coins from and to other `ModuleAccount`s or standard `Account`s 54 (`BaseAccount` or `VestingAccount`) by passing only the `Name`. 55 - `Mint` or `Burn` coins for a `ModuleAccount` (restricted to its permissions). 56 57 ### Permissions 58 59 Each `ModuleAccount` has a different set of permissions that provide different 60 object capabilities to perform certain actions. Permissions need to be 61 registered upon the creation of the supply `Keeper` so that every time a 62 `ModuleAccount` calls the allowed functions, the `Keeper` can lookup the 63 permissions to that specific account and perform or not the action. 64 65 The available permissions are: 66 67 - `Minter`: allows for a module to mint a specific amount of coins. 68 - `Burner`: allows for a module to burn a specific amount of coins. 69 - `Staking`: allows for a module to delegate and undelegate a specific amount of coins.