Skip to main content

Understanding Hash Types

For the sake of user convenience and compatibility, we expect the delivery of hashes and similar data in the form of a prefixed string when using the node. The following is a list of string representations used.

Table of Associated Hash Types


Hash and Key Explanations

PublicKey is a 32 byte asymmetric public key, preceded by a one-byte prefix that tells whether the key is ed25519 or secp256k1.

AccountHash is a 32 byte hash of the PublicKey. It serves as the address for user accounts.

ContractHash is the 32 byte hash of specific smart contract versions. You can use this to call specific contract versions.

ContractPackageHash is a 32 byte hash of the smart contract package. This hash directs you to the contract package. The function call_versioned_contract uses ContractPackageHash and allows you to call the latest version of the contract (by default). It also allows you to call any version stored previously to the package.

Key is a wrapper type that may contain one of several possible sets of data.

  • Key::Account contains an AccountHash.
  • Key::Hash contains a byte array with a length of 32, and as such can be used to pass any of the hashes. Please take note that the developer of the contract is responsible for implementation of any checks necessary on the receiving side.
  • Key::URef contains an URef suffixed by access rights.
  • Key::Transfer should contain the address hash for a transfer.
  • Key::DeployInfo retains the address hash of deploy information.
  • Key::EraInfo is the integer number of the associated era.
  • Key::Balance is the balance of a purse.
  • Key::Bid is used to keep track of bids for the auction contract. It is not generally used by users.
  • Key::Withdraw is used to keep track of withdraws for the auction contract. It is not generally used by users and exists in a historical context.
  • Key::Dictionary is the hash derived from a URef and a piece of arbitrary data and leads to a dictionary.
  • Key::SystemContractRegistry is a unique Key under which a mapping of the names and ContractHashes for system contracts, including Mint, Auction, HandlePayment and StandardPayment, is stored.
  • Key::Unbond is a variant of the key type that tracks unbonding purses.
  • Key::ChainspecRegistry is a unique Key which contains a mapping of file names to the hash of the file itself. These files include Chainspec.toml and may also include Accounts.toml and GlobalState.toml.