Skip to content

Commit 65aed48

Browse files
matiasbenaryGuillermo Alejandro Gallardo Diezbucanerojoe-rloGuillermo Alejandro Gallardo Diez
authored
Docs Quest (#2762)
* wip first step * wip: structure * wip delete components and update components * wip change styles and fix bugs * wip fix styles * wip * wip change components * wip * wip add useContext and refactor code * wip improve styles * wip improve styles * wip * feat: add validation contract * added in the first 6 lessons * chore: rm unnecesary files * wip: re-organizing sections * wip: re-organizing quests * wip * wip: fixing css * wip * chore: work on building blocks of dapps * wip * wip * feat: first version of docs quest * fix: assets folder * fix: test --------- Co-authored-by: Guillermo Alejandro Gallardo Diez <[email protected]> Co-authored-by: Damián Parrino <[email protected]> Co-authored-by: Joe <[email protected]> Co-authored-by: Guillermo Alejandro Gallardo Diez <[email protected]> Co-authored-by: Guille <[email protected]>
1 parent 06821d3 commit 65aed48

40 files changed

+3230
-13396
lines changed

docs/protocol/account-id.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: account-id
33
title: Address (Account ID)
4-
description: "Learn about NEAR account addresses - implicit addresses (64 characters) and named addresses that work as domains, including sub-account creation and management."
4+
description: "Learn all about NEAR account addresses"
55
---
66

77
import Tabs from '@theme/Tabs';
@@ -62,12 +62,39 @@ near account create-account fund-later use-auto-generation save-to-folder ~/.nea
6262

6363
# The file "~/.near-credentials/implicit/8bca86065be487de45e795b2c3154fe834d53ffa07e0a44f29e76a2a5f075df8.json" was saved successfully
6464

65-
# Here is your console command if you need to script it or re-run:
66-
# near account create-account fund-later use-auto-generation save-to-folder ~/.near-credentials/implicit
65+
cat ~/.near-credentials/implicit/8bca86065be487de45e795b2c3154fe834d53ffa07e0a44f29e76a2a5f075df8.json
66+
```
67+
68+
or `near-seed-phrase` library:
69+
70+
```js
71+
import { generateSeedPhrase } from "near-seed-phrase";
72+
const { seedPhrase, publicKey, secretKey } = generateSeedPhrase();
6773
```
6874

6975
</details>
7076

77+
<details>
78+
79+
<summary> 🧑‍💻 Technical: How to derive an implicit account from a public key </summary>
80+
81+
You can derive the implicit account address from a public key by removing the `ed25519:` prefix, decoding the resulting Base58 string into bytes, and then converting those bytes into a hexadecimal string.
82+
83+
```js
84+
// vanilla js
85+
import { decode } from 'bs58';
86+
Buffer.from(decode(publicKey.replace('ed25519:', ''))).toString('hex')
87+
```
88+
89+
```js
90+
// near-api-js
91+
import { utils } from 'near-api-js';
92+
utils.keyToImplicitAddress(publicKey);
93+
```
94+
95+
</details>
96+
97+
7198
---
7299

73100
## Named Address
@@ -83,7 +110,7 @@ An awesome feature of named accounts is that they can create **sub-accounts** of
83110
- `account.near` **cannot** create `sub.another-account.near`
84111
5. Accounts have **no control** over their sub-account, they are different entities
85112

86-
Anyone can create a `.near` or `.testnet` account, you just to call the `create_account` method of the corresponding top-level account - `testnet` on testnet, and `near` on mainnet.
113+
Anyone can create a `.near` or `.testnet` account, you just need to call the `create_account` method of the corresponding top-level account - `testnet` on testnet, and `near` on mainnet.
87114

88115
<details>
89116

@@ -145,8 +172,16 @@ You can use the same command to create sub-accounts of an existing named account
145172

146173
</details>
147174

148-
:::tip
175+
:::tip Creating Named Accounts
176+
177+
If you are not going through an intermediary (i.e. the CLI, or a wallet), then you can create an implicit account, fund it, and call `create_account` on `near` / `testnet`
178+
179+
:::
180+
181+
:::note
182+
149183
Accounts have **no control** over their sub-accounts, they are different entities. This means that `near` cannot control `bob.near`, and `bob.near` cannot control `sub.bob.near`.
184+
150185
:::
151186

152187
---

docs/quest/accounts/address.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
id: address
3+
title: Address Types
4+
description: Learn about the different types of accounts in NEAR Protocol
5+
hide_title: true
6+
---
7+
8+
import Card from '@site/src/components/UI/Card';
9+
10+
import Progress from "@site/src/components/Academy/Progress";
11+
import { Quiz, MultipleChoice, Option } from "@site/src/components/Academy/Quiz";
12+
13+
<Progress course="accounts" total={6} />
14+
15+
## Address Types in NEAR Protocol
16+
17+
Each account in NEAR protocol is identified by a **single and unique** address. While NEAR supports multiple types of addresses, most accounts use one of two: **named address** or **implicit address**.
18+
19+
<div class="row" style={{marginTop: '2rem'}}>
20+
<div class="col col--6">
21+
<Card title="Named Addresses" >
22+
Named addresses are human-readable addresses that are easy to remember and share, making them ideal for everyday use:
23+
24+
- <a>`near` / `account.near` / `account.sweat` / `app.finance.tg`</a>
25+
26+
</Card>
27+
</div>
28+
<div class="col col--6">
29+
<Card title="Implicit Address" >
30+
Implicit addresses are derived from cryptographic key pairs and are a long strings of 64 characters
31+
32+
- <a>`757503837a63ece206449d450ec77ae8d79c88ccda5e62a810f4eeb51db93050`</a>
33+
</Card>
34+
</div>
35+
</div>
36+
<div class="row" style={{marginTop: '2rem'}}>
37+
<div class="col col--6">
38+
<Card title="Ethereum Address" >
39+
NEAR Protocol supports Ethereum-like addresses to allow interoperability with EVM-based applications and tools
40+
41+
- <a>`0x32Be343B94f860124dC4fEe278FDCBD38C102D88`</a>
42+
</Card>
43+
</div>
44+
<div class="col col--6">
45+
<Card title="Other Addresses" >
46+
NEAR supports more addresses in order to accommodate various use cases, an address is valid if:
47+
48+
- <a>It has between 2 and 64 chars</a>
49+
- <a>Uses valid chars (`a-z`, `0-9`, `-`, `_`, `.`)</a>
50+
- <a>Does not start or finish on a special character (`.`,`-`,`_`)</a>
51+
52+
</Card>
53+
</div>
54+
</div>
55+
56+
---
57+
58+
## Quiz
59+
60+
<Quiz course="accounts" id="accounts-quiz">
61+
<MultipleChoice question="What are the two main types of NEAR accounts?">
62+
<Option> A. Public accounts and private accounts.</Option>
63+
<Option correct> B. Named accounts (like alice.near) and implicit accounts (like 0x123...).</Option>
64+
<Option> C. Personal accounts and business accounts.</Option>
65+
<Option> D. Main accounts and backup accounts.</Option>
66+
</MultipleChoice>
67+
<MultipleChoice question="What is a key advantage of named accounts over implicit accounts?">
68+
<Option> A. Named accounts are more secure than implicit accounts.</Option>
69+
<Option correct> B. Named accounts are human-readable and easy to remember, like alice.near.</Option>
70+
<Option> C. Named accounts cost less to create than implicit accounts.</Option>
71+
<Option> D. Named accounts can hold more tokens than implicit accounts.</Option>
72+
</MultipleChoice>
73+
<MultipleChoice question="In NEAR's hierarchical account system, who can create the sub-account 'store.bob.near'?">
74+
<Option> A. The 'near' account can create it.</Option>
75+
<Option correct> B. Only the 'bob.near' account can create it.</Option>
76+
<Option> C. Any account can create it.</Option>
77+
<Option> D. Only the registrar can create it.</Option>
78+
</MultipleChoice>
79+
<MultipleChoice question="What is the difference between a Full Access Key and a Function Call Key?">
80+
<Option> A. Full Access Keys are free, Function Call Keys cost money.</Option>
81+
<Option correct> B. Full Access Keys have complete control, Function Call Keys have limited permissions for specific contracts.</Option>
82+
<Option> C. Full Access Keys work on mainnet, Function Call Keys work on testnet.</Option>
83+
<Option> D. Full Access Keys are for named accounts, Function Call Keys are for implicit accounts.</Option>
84+
</MultipleChoice>
85+
<MultipleChoice question="How do NEAR transaction costs compare to Ethereum?">
86+
<Option> A. NEAR transactions cost more than Ethereum transactions.</Option>
87+
<Option correct> B. NEAR transactions cost tenths of a cent, while Ethereum transactions often cost dollars.</Option>
88+
<Option> C. NEAR and Ethereum have the same transaction costs.</Option>
89+
<Option> D. NEAR transactions are always free.</Option>
90+
</MultipleChoice>
91+
</Quiz>
92+
93+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
id: introduction
3+
title: Introduction
4+
description: Learn everything on NEAR accounts
5+
hide_title: true
6+
---
7+
8+
import { Quiz, MultipleChoice, Option } from "@site/src/components/Academy/Quiz";
9+
import Progress from "@site/src/components/Academy/Progress";
10+
11+
<Progress course="accounts" total={6} />
12+
13+
## Introduction to NEAR Accounts
14+
15+
Welcome to the world of NEAR accounts! In this lesson, we'll explore how NEAR Protocol's account system works and why it's designed to be more user-friendly than traditional blockchain accounts.
16+
17+
<iframe width="100%" height="360px" src="https://www.youtube-nocookie.com/embed/suUerHpmNM0?si=jG3NypPwzH83cXuY" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
18+
19+
<br />
20+
<br />
21+
22+
:::info Digital Identity
23+
24+
Think of NEAR accounts as your digital identity on the blockchain, which allows you to send and receive assets, interact with smart contracts, and interact with decentralized applications
25+
26+
:::
27+
28+
---
29+
30+
## What Makes NEAR Accounts Special?
31+
32+
**NEAR Accounts** are your personal space on the blockchain, allowing you to:
33+
- **Hold** tokens and collectibles
34+
- **Make and receive transfers**
35+
- **Create and Interact** with decentralized applications
36+
- **Control accounts on other blockchains** (like Ethereum or Bitcoin)
37+
<!-- - **Help onboard new users** by covering their transaction costs -->
38+
39+
A key difference with other chains is that, instead of having an address like `0x742d35Cc6634C0532925a3b8D`, you can have a simple named like `alice.near` which is much easier to remember and share!
40+
41+
Another unique feature of NEAR is that accounts can have multiple keys with different permission levels, allowing for more flexible and secure account management.
42+
43+
Finally, in NEAR all accounts are also smart contracts, meaning you can program them to have custom behaviors and logic!

docs/quest/accounts/keys.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
id: access-keys
3+
title: Access Keys & Permissions
4+
description: Learn about the two main types of NEAR Addresses
5+
hide_title: true
6+
---
7+
8+
import Card from '@site/src/components/UI/Card';
9+
10+
import Progress from "@site/src/components/Academy/Progress";
11+
import { Quiz, MultipleChoice, Option } from "@site/src/components/Academy/Quiz";
12+
13+
<Progress course="accounts" total={6} />
14+
15+
## Access Keys and Permissions
16+
17+
Most commonly, blockchains use a rigid system where every account is linked to a single private key that has complete control over it.
18+
19+
NEAR accounts use a more flexible and secure **access key system**, allowing accounts to have **multiple keys**, each with different permission levels.
20+
21+
<div class="row" style={{marginTop: '2rem'}}>
22+
<div class="col col--6">
23+
<Card title="Full Access Keys">
24+
<p>Full Access Keys behave like traditional private keys on other blockchains, meaning they have complete control over the account.</p>
25+
<ul>
26+
<li><a>Complete control over the account</a></li>
27+
<li><a>Like having the master key to your house</a></li>
28+
</ul>
29+
</Card>
30+
</div>
31+
<div class="col col--6">
32+
<Card title="Function Call Keys">
33+
<p>Limited permissions for specific smart contracts and operations.</p>
34+
<ul>
35+
<li><a>Call specific smart contracts</a></li>
36+
<li><a>Call specific functions on the contract</a></li>
37+
<li><a>Like a key that only works on specific rooms</a></li>
38+
</ul>
39+
</Card>
40+
</div>
41+
</div>
42+
43+
---
44+
45+
## Why This Matters
46+
47+
There are multiple advantages to using multiple access keys with different permissions:
48+
49+
1. **Key rotation**: If one key is compromised, you can replace it without losing your account
50+
2. **Granular permissions**: Different keys can have different levels of access
51+
3. **Third-party integration**: Apps can request limited permissions to your account to do specific tasks for you
52+
53+
---
54+
55+
## Why Function Call Keys?
56+
57+
<div class="row">
58+
<div class="col col--6">
59+
Imagine you are playing a game that registers your score on the blockchain.
60+
61+
On other protocols this will require you to either share your private key with the game (truly terrible idea), or to sign every single transaction manually.
62+
63+
With NEAR, the game can request a `Function Call Key` that **only allows** it call a function to update score on your behalf, **nothing else**.
64+
65+
</div>
66+
<div class="col col--6">
67+
<video width="100%" height="215" frameborder="0" autoplay loop allowfullscreen controls>
68+
<source src="/assets/docs/quest/accounts/sign.mp4" type="video/mp4" />
69+
</video>
70+
*This is **not** what the future of web3 gaming looks like*
71+
</div>
72+
</div>
73+
74+
---
75+
76+
## Quiz
77+
78+
<Quiz course="accounts" id="accounts-quiz">
79+
<MultipleChoice question="What is the difference between a Full Access Key and a Function Call Key?">
80+
<Option> A. Full Access Keys are free, Function Call Keys cost money.</Option>
81+
<Option correct> B. Full Access Keys have complete control, Function Call Keys have limited permissions for specific contracts.</Option>
82+
<Option> C. Full Access Keys work on mainnet, Function Call Keys work on testnet.</Option>
83+
<Option> D. Full Access Keys are for named accounts, Function Call Keys are for implicit accounts.</Option>
84+
</MultipleChoice>
85+
</Quiz>
86+
87+

0 commit comments

Comments
 (0)