Search code examples
blockchainsmartcontractsnearprotocol

How named accounts works in NEAR


It appears that named accounts in NEAR are being managed by the near and register smart contracts. However, this raises the question of whether NEAR natively supports named accounts. it's unclear if the smart contracts simply maintain a mapping between implicit accounts and their corresponding names or if named accounts are natively supported at the blockchain layer. anyone knows how it works?


Solution

  • NEAR Protocol provides a unique approach to account identification. Named accounts in NEAR are natively supported and are a fundamental part of the protocol’s design.

    In NEAR, an account ID is a human-readable name, similar to an email address. Account IDs can be hierarchical, meaning they can be subnames of other accounts, akin to subdomains.

    For example, if there’s an account with ID “example.near”, you can create a subaccount under this account, like “sub.example.near”. In this hierarchy, only the “example.near” account can create subaccounts that end with “.example.near”.

    However, the account IDs are not managed by smart contracts. The NEAR protocol itself handles the creation, deletion, and management of these accounts. Accounts and their associated state (like account balance and contract state) are stored in the NEAR Protocol’s underlying state trie, a merkle tree that is used for storing the blockchain’s state.

    The “near” contract you mentioned might be application-specific contracts that work on top of the basic account system.