AminoMsg vs EncodeObject
An Amino message looks like:
StdSignDoc
The Amino sign document is a JSON object with sorted keys:- Build
StdSignDocwithmakeSignDoc() - Sort all keys deterministically with
sortedJsonStringify() - Escape
&,<,>characters - Convert to UTF-8 bytes
- Hash with SHA-256 and sign
AminoTypes: Converting Between Formats
AminoTypes (from @cosmjs/stargate) bridges the two worlds. It converts
EncodeObject ↔ AminoMsg using registered converters:
- Converts each
EncodeObjecttoAminoMsgviaaminoTypes.toAmino() - Builds a
StdSignDocand signs it - Converts the signed messages back via
aminoTypes.fromAmino() - Encodes the final transaction as Protobuf (even Amino-signed transactions
are broadcast as Protobuf
TxRaw)