github.com/Finschia/finschia-sdk@v0.49.1/x/auth/spec/02_state.md (about) 1 <!-- 2 order: 2 3 --> 4 5 # State 6 7 ## Accounts 8 9 Accounts contain authentication information for a uniquely identified external user of an SDK blockchain, 10 including public key, address, and account number / sequence number for replay protection. For efficiency, 11 since account balances must also be fetched to pay fees, account structs also store the balance of a user 12 as `sdk.Coins`. 13 14 Accounts are exposed externally as an interface, and stored internally as 15 either a base account or vesting account. Module clients wishing to add more 16 account types may do so. 17 18 - `0x01 | Address -> ProtocolBuffer(account)` 19 20 ### Account Interface 21 22 The account interface exposes methods to read and write standard account information. 23 Note that all of these methods operate on an account struct confirming to the 24 interface - in order to write the account to the store, the account keeper will 25 need to be used. 26 27 ```go 28 // AccountI is an interface used to store coins at a given address within state. 29 // It presumes a notion of sequence numbers for replay protection, 30 // a notion of account numbers for replay protection for previously pruned accounts, 31 // and a pubkey for authentication purposes. 32 // 33 // Many complex conditions can be used in the concrete struct which implements AccountI. 34 type AccountI interface { 35 proto.Message 36 37 GetAddress() sdk.AccAddress 38 SetAddress(sdk.AccAddress) error // errors if already set. 39 40 GetPubKey() crypto.PubKey // can return nil. 41 SetPubKey(crypto.PubKey) error 42 43 GetAccountNumber() uint64 44 SetAccountNumber(uint64) error 45 46 GetSequence() uint64 47 SetSequence(uint64) error 48 49 // Ensure that account implements stringer 50 String() string 51 } 52 ``` 53 54 #### Base Account 55 56 A base account is the simplest and most common account type, which just stores all requisite 57 fields directly in a struct. 58 59 ```protobuf 60 // BaseAccount defines a base account type. It contains all the necessary fields 61 // for basic account functionality. Any custom account type should extend this 62 // type for additional functionality (e.g. vesting). 63 message BaseAccount { 64 string address = 1; 65 google.protobuf.Any pub_key = 2; 66 uint64 account_number = 3; 67 uint64 sequence = 4; 68 } 69 ``` 70 71 ### Vesting Account 72 73 See [Vesting](05_vesting.md).