Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Account ID

note

An immutable and unique identifier for the Account.

The Account ID is a 120-bit long number. This identifier is designed to contain the metadata of an account. The metadata includes the account type, account storage mode and the version of the Account. This metadata is included in the ID to ensure it can be read without needing the full account state.

The ID is generated by hashing a randomly generated seed together with commitments to the initial code and storage of the Account until the resulting ID has the desired account type and storage mode. This process requires a small amount of Proof-of-Work (9 bits) that can be done even by low-powered devices. The resulting 256-bit hash is shortened to 120 bits.

Account type and storage mode are chosen at account creation time and cannot be changed later.

Account type

There are two main categories of accounts in Miden: basic accounts and faucets.

  • Basic Accounts: Basic Accounts may be either mutable or immutable:

    • Mutable: Code can be changed after deployment.
    • Immutable: Code cannot be changed once deployed.
  • Faucets: Faucets are always immutable and can be specialized by the type of assets they issue:

    • Fungible Faucet: Can issue fungible assets.
    • Non-fungible Faucet: Can issue non-fungible assets.

Account storage mode

Users can choose whether their accounts are stored publicly or privately. The preference is encoded in the third and fourth most significant bits of the account's ID:

  • Public Accounts: The account's state is stored on-chain, similar to how accounts are stored in public blockchains like Ethereum.

  • Network Accounts: The account's state is stored on-chain, just like public accounts. Additionally, the network will monitor this account for any public notes targeted at it and attempt to create network transactions against the account, which consume the notes. Contracts that rely on a shared, publicly accessible state (e.g., an AMM) should be network accounts.

  • Private Accounts: Only a commitment (hash) to the account's state is stored on-chain. This mode is suitable for users who prioritize privacy or plan to store a large amount of data in their Account. To interact with a private Account, a user must have knowledge of its interface.

Encoding

An Account ID can be encoded in different formats:

  1. Bech32 (user-facing):

    • Example: mm1qzqge9n53l5dpyqav7y0d2j0ggl3dc9m
    • Benefits:
      • Built-in error detection via checksum algorithm
      • Human-readable prefix indicates network type
      • Less prone to transcription errors
    • Structure:
      • Human-readable prefix that determines the network:
        • mm (indicates Miden Mainnet)
        • mtst (indicates Miden Testnet)
        • mdev (indicates Miden Devnet)
      • Separator: 1
      • Data part with integrated checksum
  2. Hexadecimal (debugging):

    • Example: 0x808c96748fe8d0901d6788f6aa4f42
    • Frequently used encoding for blockchain addresses

Info

  • We strongly recommend encoding account IDs using Bech32 for all user-facing applications.