Skip to main content

Module digests

Module digests 

Source
Expand description

Utilities for working with chain identifier strings.

A chain identifier can appear in two formats:

  • the legacy short form: the first 4 bytes of the digest, hex-encoded, e.g. 35834a8a. This is the format returned by JSON-RPC, the format rendered by ChainIdentifier’s Display, and the only format this tooling ever writes — into Move.toml and client.yaml.
  • the full Base58 form: the full genesis checkpoint digest, Base58-encoded (the format returned by the gRPC and GraphQL APIs), e.g. 4btiuiMPvEENsttpZC7CZ53DruC3MAgfznDbASZ7DR6S.

We never write the Base58 form, but a user may paste it (e.g. copied from a gRPC/GraphQL response or an explorer) into a Move.toml [environments] entry, while the CLI environment and client.yaml cache hold the hex short form. Comparisons must therefore treat the two encodings of the same digest as equal.

Functions§

chain_id_base58
The full Base58-encoded genesis checkpoint digest for chain_id — the canonical chain identifier format. (ChainIdentifier’s Display renders the legacy 4-byte hex short form.)
chain_ids_match
Compare two chain identifier strings, each of which may independently be in the canonical Base58 form or the legacy hex short form. A short form matches a full form if it encodes the first 4 bytes of the digest. Strings in neither format (e.g. ad-hoc identifiers used by tests or other flavors) only match by exact string equality.