2019-12-17 03:44:44 -08:00
|
|
|
<!--
|
2019-12-11 09:35:27 -08:00
|
|
|
order: 2
|
2019-12-17 03:44:44 -08:00
|
|
|
-->
|
2019-12-11 09:35:27 -08:00
|
|
|
|
2019-02-20 10:21:57 -08:00
|
|
|
# State
|
2018-12-05 16:48:08 -08:00
|
|
|
|
2019-02-20 10:21:57 -08:00
|
|
|
## Accounts
|
2018-12-05 16:48:08 -08:00
|
|
|
|
|
|
|
Accounts contain authentication information for a uniquely identified external user of an SDK blockchain,
|
|
|
|
including public key, address, and account number / sequence number for replay protection. For efficiency,
|
|
|
|
since account balances must also be fetched to pay fees, account structs also store the balance of a user
|
|
|
|
as `sdk.Coins`.
|
|
|
|
|
|
|
|
Accounts are exposed externally as an interface, and stored internally as
|
|
|
|
either a base account or vesting account. Module clients wishing to add more
|
|
|
|
account types may do so.
|
|
|
|
|
|
|
|
- `0x01 | Address -> amino(account)`
|
|
|
|
|
2019-02-20 10:21:57 -08:00
|
|
|
### Account Interface
|
2018-12-05 16:48:08 -08:00
|
|
|
|
|
|
|
The account interface exposes methods to read and write standard account information.
|
|
|
|
Note that all of these methods operate on an account struct confirming to the interface
|
|
|
|
- in order to write the account to the store, the account keeper will need to be used.
|
|
|
|
|
2019-08-26 06:09:18 -07:00
|
|
|
```go
|
2018-12-05 16:48:08 -08:00
|
|
|
type Account interface {
|
|
|
|
GetAddress() AccAddress
|
|
|
|
SetAddress(AccAddress)
|
|
|
|
|
|
|
|
GetPubKey() PubKey
|
|
|
|
SetPubKey(PubKey)
|
|
|
|
|
|
|
|
GetAccountNumber() uint64
|
|
|
|
SetAccountNumber(uint64)
|
|
|
|
|
|
|
|
GetSequence() uint64
|
|
|
|
SetSequence(uint64)
|
|
|
|
|
|
|
|
GetCoins() Coins
|
|
|
|
SetCoins(Coins)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Base Account
|
|
|
|
|
|
|
|
A base account is the simplest and most common account type, which just stores all requisite
|
|
|
|
fields directly in a struct.
|
|
|
|
|
2019-08-26 06:09:18 -07:00
|
|
|
```go
|
2018-12-05 16:48:08 -08:00
|
|
|
type BaseAccount struct {
|
|
|
|
Address AccAddress
|
|
|
|
Coins Coins
|
|
|
|
PubKey PubKey
|
|
|
|
AccountNumber uint64
|
|
|
|
Sequence uint64
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-02-20 10:21:57 -08:00
|
|
|
### Vesting Account
|
2018-12-05 16:48:08 -08:00
|
|
|
|
|
|
|
See [Vesting](vesting.md).
|