API Reference

The interfaces a module author implements and the runtime entry points they plug into.

Path: api-reference

Third-party documentation. This is independently authored analysis of the public Cosmos SDK codebase — not the official docs, and not reviewed or endorsed by the Cosmos SDK team.

API Reference

Module authors touch a compact set of interfaces; everything else is per-module code.

Module lifecycle

  • AppModule.Name() — unique module identifier used in wiring and genesis keys.
  • RegisterServices(Configurator) — attach Msg and Query gRPC services.
  • RegisterLegacyAminoCodec / RegisterInterfaces(InterfaceRegistry) — codec registration for tx decoding and protobuf any-wrapping.
  • InitGenesis(ctx, json) / ExportGenesis(ctx) — deterministic state bootstrap/export.
  • BeginBlock / EndBlock (optional interfaces) — per-block hooks, sequenced by the module manager.

Keeper toolkit

  • KVStoreService.OpenKVStore(ctx) — scoped store handle; all reads/writes flow through it under gas metering.
  • codec.Codec — protobuf binary + JSON marshaling for state entries and genesis.
  • Address codecs and coin utilities from the types package for account/value handling.

Runtime composition

  • module.Manager — registration plus explicit BeginBlocker/EndBlocker ordering.
  • runtime.AppBuilder.Build(...) — assembles baseapp with the configured module set and wiring options.
  • Ante decorator chain — pluggable pre-execution pipeline (signatures, fees, gas) shared by all modules.

Standard library modules

x/bank (transfers), x/staking, x/gov, x/slashing, x/distribution, x/upgrade, x/auth — the composable baseline every app chain starts from, each itself an example of the module pattern.

Interface

Interface
go
// Module lifecycle (AppModule)
type HasRegisterInterfaces interface{ RegisterInterfaces(registry InterfaceRegistry) }
type HasAminoInterface interface{ RegisterLegacyAminoCodec(amino *codec.LegacyAmino) }
type AppModule interface {
Name() string
RegisterServices(cfg Configurator) // Msg + Query gRPC services
InitGenesis(ctx Context, bz codec.JSON) []byte
ExportGenesis(ctx Context) codec.JSON
}
 
// Keeper surface
type KVStoreService / MemStoreService // scoped store access
codec.Codec // binary + JSON (de)serialization
 
// Runtime
module.Manager{ Modules: [...] } // registration + hook sequencing
runtime.AppBuilder // composes baseapp from wiring config
 
STATUSinterface