Web3 Fundamentals · 3 min read
Accounts and Named Accounts
NEAR accounts are human-readable names like alice.near, with sub-accounts, implicit accounts, and balances you can read in one RPC call.
On most chains your "account" is a long hex address derived from a key. On NEAR the account is a name. alice.near is not an alias that points somewhere else; it is the account, and it holds a balance, a set of keys, and optionally one smart contract.
Kinds of accounts
| Kind | Example | Notes |
|---|---|---|
| Top-level named | alice.near, alice.testnet | Created through the near or testnet registrar. |
| Sub-account | diploma.retr0school.testnet | Only retr0school.testnet can create it. Great for organizing apps. |
| Implicit | 98793cd9…a8f (64 hex chars) | Derived from a public key. Exists as soon as it receives NEAR. |
| ETH-implicit | 0x… | Lets Ethereum wallets use NEAR directly. |
This course runs on testnet, so accounts end in .testnet. The diploma contract you will mint from lives at diploma.retr0school.testnet, a sub-account of retr0school.testnet.
Read an account
Every account's balance and storage use are public. Run the example, then try your own testnet account.
<h1>NEAR account lookup</h1>
<input id="acc" value="retr0school.testnet">
<button id="go">Look up</button>
<pre id="out">Press Look up.</pre>Edit this example in the Playground.
Units
NEAR has 24 decimals. The smallest unit is the yoctoNEAR: 1 NEAR = 10^24 yocto. RPC responses return balances as strings in yocto, which is why the example uses BigInt.
Exercise
Look up demo-learner.retr0school.testnet on the testnet explorer and note its balance. Then explain the difference between that named account and an implicit account made from a public key.
Saved in this browser.