cosmos-sdk/x/auth/spec/03_types.md

71 lines
1.8 KiB
Markdown

<!--
order: 4
-->
# Types
Besides accounts (specified in [State](02_state.md)), the types exposed by the auth module
are `StdFee`, the combination of an amount and gas limit, `StdSignature`, the combination
of an optional public key and a cryptographic signature as a byte array, `StdTx`,
a struct which implements the `sdk.Tx` interface using `StdFee` and `StdSignature`, and
`StdSignDoc`, a replay-prevention structure for `StdTx` which transaction senders must sign over.
## StdFee
A `StdFee` is simply the combination of a fee amount, in any number of denominations,
and a gas limit (where dividing the amount by the gas limit gives a "gas price").
```go
type StdFee struct {
Amount Coins
Gas uint64
}
```
## StdSignature
A `StdSignature` is the combination of an optional public key and a cryptographic signature
as a byte array. The SDK is agnostic to particular key or signature formats and supports any
supported by the `PubKey` interface.
```go
type StdSignature struct {
PubKey PubKey
Signature []byte
}
```
## StdTx
A `StdTx` is a struct which implements the `sdk.Tx` interface, and is likely to be generic
enough to serve the purposes of many Cosmos SDK blockchains.
```go
type StdTx struct {
Msgs []sdk.Msg
Fee StdFee
Signatures []StdSignature
Memo string
}
```
## StdSignDoc
A `StdSignDoc` is a replay-prevention structure to be signed over, which ensures that
any submitted transaction (which is simply a signature over a particular bytestring)
will only be executable once on a particular blockchain.
`json.RawMessage` is preferred over using the SDK types for future compatibility.
```go
type StdSignMsg struct {
ChainID string
AccountNumber uint64
Sequence uint64
TimeoutHeight uint64
Fee StdFee
Msgs []sdk.Msg
Memo string
}
```