Skip to content

Commit adc1f9b

Browse files
Standardize example documentation across all READMEs
- Add Example Documentation section to main README describing the shared README structure (Overview, Difficulty, Concepts, Deploy & Run, etc.) - Add README column to category tables and link Example Index to README files - Fix Example Index: add Difficulty column, correct test coverage, move snipe-prevention to Intermediate to match its content level - Standardize all snippet READMEs on a Deploy & Run section with package path, named address table, and consistent Deploy/Tests/Prover subsections - Update move-2 README with cross-links and expanded feature table - Add snipe-prevention and move-2 to project structure tree Co-authored-by: Greg Nazario <greg@gnazar.io>
1 parent e3eb282 commit adc1f9b

19 files changed

Lines changed: 264 additions & 93 deletions

File tree

README.md

Lines changed: 67 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ A curated collection of Move language examples for the [Aptos](https://aptos.dev
1111
- [Overview](#overview)
1212
- [Prerequisites](#prerequisites)
1313
- [Quick Start](#quick-start)
14+
- [Example Documentation](#example-documentation)
1415
- [Examples by Category](#examples-by-category)
1516
- [Beginner](#beginner)
1617
- [Intermediate](#intermediate)
1718
- [Advanced](#advanced)
1819
- [Example Index](#example-index)
1920
- [Concepts Covered](#concepts-covered)
2021
- [Project Structure](#project-structure)
22+
- [Named Addresses](#named-addresses)
2123

2224
---
2325

@@ -76,63 +78,82 @@ After deploying, interact with your contract via the [Aptos Explorer](https://ex
7678

7779
---
7880

81+
## Example Documentation
82+
83+
Every example has a `README.md` in its package directory. Each follows the same structure so you can scan any example quickly:
84+
85+
| Section | Description |
86+
|---------|-------------|
87+
| **Overview** | What the example demonstrates and when to use it |
88+
| **Difficulty** | `Beginner`, `Intermediate`, or `Advanced` |
89+
| **Concepts Demonstrated** | Move language and Aptos framework topics covered |
90+
| **Key Structs / Key Functions** | Tables summarizing the main types and entry points |
91+
| **Deploy & Run** | Package path, named address, and commands to deploy, test, or run the prover |
92+
| **Related Examples** | Cross-links to similar or prerequisite examples |
93+
94+
See [Named Addresses](#named-addresses) below for the address placeholder each package expects at deploy time.
95+
96+
For a summary of Move 2 features used across examples, see [snippets/move-2/README.md](snippets/move-2/README.md).
97+
98+
---
99+
79100
## Examples by Category
80101

81102
### Beginner
82103

83-
| Example | Directory | Description |
84-
|---------|-----------|-------------|
85-
| [Error Codes](snippets/error-codes/) | `snippets/error-codes/` | How to define and use error codes with doc comments for readable error messages |
86-
| [Objects (Sticky Notes)](snippets/objects/) | `snippets/objects/` | Introduction to the Aptos Object model, comparing resources vs objects |
87-
| [Private vs Public Functions](snippets/private-vs-public/) | `snippets/private-vs-public/` | Function visibility and why it matters for security (with a cheater example) |
104+
| Example | Directory | README | Description |
105+
|---------|-----------|--------|-------------|
106+
| [Error Codes](snippets/error-codes/) | `snippets/error-codes/` | [README](snippets/error-codes/README.md) | How to define and use error codes with doc comments for readable error messages |
107+
| [Objects (Sticky Notes)](snippets/objects/) | `snippets/objects/` | [README](snippets/objects/README.md) | Introduction to the Aptos Object model, comparing resources vs objects |
108+
| [Private vs Public Functions](snippets/private-vs-public/) | `snippets/private-vs-public/` | [README](snippets/private-vs-public/README.md) | Function visibility and why it matters for security (with a cheater example) |
88109

89110
### Intermediate
90111

91-
| Example | Directory | Description |
92-
|---------|-----------|-------------|
93-
| [Controlled Mint](snippets/controlled-mint/) | `snippets/controlled-mint/` | Creator-controlled NFT minting with royalty support |
94-
| [Data Structures (Min Heap)](snippets/data-structures/heap/) | `snippets/data-structures/heap/` | Min heap implementation with formal verification specs |
95-
| [Design Patterns: Autonomous Objects](snippets/design-patterns/autonomous-objects/) | `snippets/design-patterns/autonomous-objects/` | Creating objects that can act autonomously via extend refs |
96-
| [Modifying NFTs](snippets/modifying-nfts/) | `snippets/modifying-nfts/` | How to modify NFT properties, URIs, and extend collections with custom data |
97-
| [Parallel NFT Minting](snippets/parallel-nfts/) | `snippets/parallel-nfts/` | Parallelized NFT minting using object-owned collections |
98-
| [Storage Patterns](snippets/storage/) | `snippets/storage/` | Comparison of Vector, SimpleMap, Table, SmartTable, and SmartVector with gas benchmarks |
99-
| [Struct Capabilities (Mailbox)](snippets/struct-capabilities/) | `snippets/struct-capabilities/` | Using structs for capability-based access control in a mailbox system |
112+
| Example | Directory | README | Description |
113+
|---------|-----------|--------|-------------|
114+
| [Controlled Mint](snippets/controlled-mint/) | `snippets/controlled-mint/` | [README](snippets/controlled-mint/README.md) | Creator-controlled NFT minting with royalty support |
115+
| [Data Structures (Min Heap)](snippets/data-structures/heap/) | `snippets/data-structures/heap/` | [README](snippets/data-structures/heap/README.md) | Min heap implementation with formal verification specs |
116+
| [Design Patterns: Autonomous Objects](snippets/design-patterns/autonomous-objects/) | `snippets/design-patterns/autonomous-objects/` | [README](snippets/design-patterns/autonomous-objects/README.md) | Creating objects that can act autonomously via extend refs |
117+
| [Modifying NFTs](snippets/modifying-nfts/) | `snippets/modifying-nfts/` | [README](snippets/modifying-nfts/README.md) | How to modify NFT properties, URIs, and extend collections with custom data |
118+
| [Parallel NFT Minting](snippets/parallel-nfts/) | `snippets/parallel-nfts/` | [README](snippets/parallel-nfts/README.md) | Parallelized NFT minting using object-owned collections |
119+
| [Snipe Prevention](snippets/snipe-prevention/) | `snippets/snipe-prevention/` | [README](snippets/snipe-prevention/README.md) | Anti-snipe protection for token launches using dispatchable fungible assets |
120+
| [Storage Patterns](snippets/storage/) | `snippets/storage/` | [README](snippets/storage/README.md) | Comparison of Vector, SimpleMap, Table, SmartTable, and SmartVector with gas benchmarks |
121+
| [Struct Capabilities (Mailbox)](snippets/struct-capabilities/) | `snippets/struct-capabilities/` | [README](snippets/struct-capabilities/README.md) | Using structs for capability-based access control in a mailbox system |
100122

101123
### Advanced
102124

103-
| Example | Directory | Description |
104-
|---------|-----------|-------------|
105-
| [Composable NFTs](snippets/composable-nfts/) | `snippets/composable-nfts/` | Dynamic composable NFTs where a Face can equip/unequip a Hat, changing the token image |
106-
| [FA Lockup / Escrow](snippets/fa-lockup-example/) | `snippets/fa-lockup-example/` | Time-locked fungible asset escrow with dispatchable transfers |
107-
| [Fractional Token](snippets/fractional-token/) | `snippets/fractional-token/` | Fractionalizing a digital asset into fungible tokens and recombining them |
108-
| [Liquid NFTs](snippets/liquid-nfts/) | `snippets/liquid-nfts/` | NFT liquidity pools using Coin, Legacy Token, and Fungible Asset standards |
109-
| [Lootbox / Mystery Box](snippets/lootbox/) | `snippets/lootbox/` | On-chain mystery boxes using Aptos randomness, supporting coins, FAs, and NFTs |
110-
| [Prover (Payment Escrow)](snippets/prover/) | `snippets/prover/` | Formal verification with the Move Prover on a payment escrow contract |
111-
| [Snipe Prevention](snippets/snipe-prevention/) | `snippets/snipe-prevention/` | Anti-snipe protection for token launches using dispatchable fungible assets |
125+
| Example | Directory | README | Description |
126+
|---------|-----------|--------|-------------|
127+
| [Composable NFTs](snippets/composable-nfts/) | `snippets/composable-nfts/` | [README](snippets/composable-nfts/README.md) | Dynamic composable NFTs where a Face can equip/unequip a Hat, changing the token image |
128+
| [FA Lockup / Escrow](snippets/fa-lockup-example/) | `snippets/fa-lockup-example/` | [README](snippets/fa-lockup-example/README.md) | Time-locked fungible asset escrow with dispatchable transfers |
129+
| [Fractional Token](snippets/fractional-token/) | `snippets/fractional-token/` | [README](snippets/fractional-token/README.md) | Fractionalizing a digital asset into fungible tokens and recombining them |
130+
| [Liquid NFTs](snippets/liquid-nfts/) | `snippets/liquid-nfts/` | [README](snippets/liquid-nfts/README.md) | NFT liquidity pools using Coin, Legacy Token, and Fungible Asset standards |
131+
| [Lootbox / Mystery Box](snippets/lootbox/) | `snippets/lootbox/` | [README](snippets/lootbox/README.md) | On-chain mystery boxes using Aptos randomness, supporting coins, FAs, and NFTs |
132+
| [Prover (Payment Escrow)](snippets/prover/) | `snippets/prover/` | [README](snippets/prover/README.md) | Formal verification with the Move Prover on a payment escrow contract |
112133

113134
---
114135

115136
## Example Index
116137

117-
| # | Example | Key Concepts | Move 2 Features Used | Has Tests |
118-
|---|---------|-------------|---------------------|-----------|
119-
| 1 | [error-codes](snippets/error-codes/) | Error codes, doc comments, `abort`, `assert!` | Receiver style | No |
120-
| 2 | [objects](snippets/objects/) | Object model, resources vs objects, `ExtendRef`, `DeleteRef`, `TransferRef` | Receiver style, index notation | No |
121-
| 3 | [private-vs-public](snippets/private-vs-public/) | Function visibility (`public`, `public entry`, `entry`, private), security | Receiver style, index notation | No |
122-
| 4 | [controlled-mint](snippets/controlled-mint/) | Token V2 minting, collections, royalties, named objects | Receiver style, index notation, `for` loops | No |
123-
| 5 | [data-structures/heap](snippets/data-structures/heap/) | Min heap, heap sort, formal verification specs | Receiver style, `for` loops | Yes |
124-
| 6 | [design-patterns/autonomous-objects](snippets/design-patterns/autonomous-objects/) | Autonomous object pattern, ownership permission pattern | Receiver style, index notation | No |
125-
| 7 | [modifying-nfts](snippets/modifying-nfts/) | Mutable NFTs, `MutatorRef`, `BurnRef`, extending objects | Receiver style, index notation | No |
126-
| 8 | [parallel-nfts](snippets/parallel-nfts/) | Parallelized minting, object-owned collections, numbered tokens | Receiver style, index notation | No |
127-
| 9 | [storage](snippets/storage/) | Vector, SimpleMap, Table, SmartTable, SmartVector, gas comparison | Receiver style, index notation, `for` loops | No |
128-
| 10 | [struct-capabilities](snippets/struct-capabilities/) | Capability pattern, `SmartTable`, `SmartVector`, envelopes | Receiver style, index notation | No |
129-
| 11 | [composable-nfts](snippets/composable-nfts/) | Composable tokens, dynamic URIs, transfer locking | Receiver style, index notation | Yes |
130-
| 12 | [fa-lockup-example](snippets/fa-lockup-example/) | Fungible asset escrow, time locks, enum types, `match` | Receiver style, index notation, enums, `match`, `for` loops | Yes |
131-
| 13 | [fractional-token](snippets/fractional-token/) | Fractionalization, fungible assets, primary stores | Receiver style, index notation | Yes |
132-
| 14 | [liquid-nfts](snippets/liquid-nfts/) | Liquidity pools, Coin vs FA, legacy tokens, pseudorandom | Receiver style, index notation, `for` loops | Yes |
133-
| 15 | [lootbox](snippets/lootbox/) | Randomness API, multi-asset boxes, soulbound tickets | Receiver style, index notation, `for` loops | No |
134-
| 16 | [prover](snippets/prover/) | Move Prover, formal specs, invariants, schemas | Receiver style, index notation | No |
135-
| 17 | [snipe-prevention](snippets/snipe-prevention/) | Dispatchable FA hooks, anti-snipe, allowlists, enum types | Receiver style, index notation, enums, `match` | Yes |
138+
| # | Example | Difficulty | Key Concepts | Move 2 Features Used | Tests |
139+
|---|---------|------------|-------------|---------------------|-------|
140+
| 1 | [error-codes](snippets/error-codes/README.md) | Beginner | Error codes, doc comments, `abort`, `assert!` | Receiver style | Yes |
141+
| 2 | [objects](snippets/objects/README.md) | Beginner | Object model, resources vs objects, `ExtendRef`, `DeleteRef`, `TransferRef` | Receiver style, index notation | |
142+
| 3 | [private-vs-public](snippets/private-vs-public/README.md) | Beginner | Function visibility (`public`, `public entry`, `entry`, private), security | Receiver style, index notation | |
143+
| 4 | [controlled-mint](snippets/controlled-mint/README.md) | Intermediate | Token V2 minting, collections, royalties, named objects | Receiver style, index notation, `for` loops | Yes |
144+
| 5 | [data-structures/heap](snippets/data-structures/heap/README.md) | Intermediate | Min heap, heap sort, formal verification specs | Receiver style, `for` loops | Yes + Prover |
145+
| 6 | [design-patterns/autonomous-objects](snippets/design-patterns/autonomous-objects/README.md) | Intermediate | Autonomous object pattern, ownership permission pattern | Receiver style, index notation | |
146+
| 7 | [modifying-nfts](snippets/modifying-nfts/README.md) | Intermediate | Mutable NFTs, `MutatorRef`, `BurnRef`, extending objects | Receiver style, index notation | |
147+
| 8 | [parallel-nfts](snippets/parallel-nfts/README.md) | Intermediate | Parallelized minting, object-owned collections, numbered tokens | Receiver style, index notation | |
148+
| 9 | [snipe-prevention](snippets/snipe-prevention/README.md) | Intermediate | Dispatchable FA hooks, anti-snipe, allowlists, enum types | Receiver style, index notation, enums, `match` | Yes |
149+
| 10 | [storage](snippets/storage/README.md) | Intermediate | Vector, SimpleMap, Table, SmartTable, SmartVector, gas comparison | Receiver style, index notation, `for` loops | |
150+
| 11 | [struct-capabilities](snippets/struct-capabilities/README.md) | Intermediate | Capability pattern, `SmartTable`, `SmartVector`, envelopes | Receiver style, index notation | |
151+
| 12 | [composable-nfts](snippets/composable-nfts/README.md) | Advanced | Composable tokens, dynamic URIs, transfer locking | Receiver style, index notation | Yes |
152+
| 13 | [fa-lockup-example](snippets/fa-lockup-example/README.md) | Advanced | Fungible asset escrow, time locks, enum types, `match` | Receiver style, index notation, enums, `match`, `for` loops | Yes |
153+
| 14 | [fractional-token](snippets/fractional-token/README.md) | Advanced | Fractionalization, fungible assets, primary stores | Receiver style, index notation | Yes |
154+
| 15 | [liquid-nfts](snippets/liquid-nfts/README.md) | Advanced | Liquidity pools, Coin vs FA, legacy tokens, pseudorandom | Receiver style, index notation, `for` loops | Yes |
155+
| 16 | [lootbox](snippets/lootbox/README.md) | Advanced | Randomness API, multi-asset boxes, soulbound tickets | Receiver style, index notation, `for` loops | |
156+
| 17 | [prover](snippets/prover/README.md) | Advanced | Move Prover, formal specs, invariants, schemas | Receiver style, index notation | Prover |
136157

137158
---
138159

@@ -255,6 +276,10 @@ snippets/
255276
│ ├── Move.toml
256277
│ └── sources/
257278
│ └── antisnipe_token.move
279+
├── snipe-prevention/ # Anti-snipe protection for token launches
280+
│ ├── Move.toml
281+
│ └── sources/
282+
│ └── antisnipe_token.move
258283
├── storage/ # Data structure comparison with gas benchmarks
259284
│ ├── Move.toml
260285
│ └── sources/

snippets/composable-nfts/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,23 @@ Advanced
5555
- Restore Face description -> "Face wifout hat"
5656
```
5757

58-
## Running Tests
58+
## Deploy & Run
59+
60+
| | |
61+
|---|---|
62+
| **Package** | `snippets/composable-nfts` |
63+
| **Named address** | `deploy_addr` |
64+
65+
### Deploy
5966

6067
```bash
61-
aptos move test --dev --package-dir snippets/composable-nfts
68+
aptos move publish --named-addresses deploy_addr=default --package-dir snippets/composable-nfts
6269
```
6370

64-
## Deploy
71+
### Tests
6572

6673
```bash
67-
aptos move publish --named-addresses deploy_addr=default --package-dir snippets/composable-nfts
74+
aptos move test --dev --package-dir snippets/composable-nfts
6875
```
6976

7077
## Related Examples

snippets/controlled-mint/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,25 @@ Intermediate
3838
2. **Create a collection** via `create_collection` with name, description, URI, and optional royalty
3939
3. **Mint tokens** via `mint` by passing vectors of descriptions, URIs, and destination addresses
4040

41-
## Deploy & Test
41+
## Deploy & Run
42+
43+
| | |
44+
|---|---|
45+
| **Package** | `snippets/controlled-mint` |
46+
| **Named address** | `deploy_addr` |
47+
48+
### Deploy
4249

4350
```bash
4451
aptos move publish --named-addresses deploy_addr=default --package-dir snippets/controlled-mint
4552
```
4653

54+
### Tests
55+
56+
```bash
57+
aptos move test --dev --package-dir snippets/controlled-mint
58+
```
59+
4760
## Related Examples
4861

4962
- [Parallel NFT Minting](../parallel-nfts/) -- Public minting with parallelization

snippets/data-structures/heap/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,20 @@ Intermediate
4646
| `from_vec` | O(n log n) | O(1) |
4747
| `heap_sort` | O(n log n) | O(n) |
4848

49-
## Running Tests
49+
## Deploy & Run
50+
51+
| | |
52+
|---|---|
53+
| **Package** | `snippets/data-structures/heap` |
54+
| **Named address** | `deploy_addr` |
55+
56+
### Tests
5057

5158
```bash
5259
aptos move test --dev --package-dir snippets/data-structures/heap
5360
```
5461

55-
## Running the Prover
62+
### Prover
5663

5764
```bash
5865
aptos move prove --dev --package-dir snippets/data-structures/heap

snippets/design-patterns/autonomous-objects/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ let object = object::address_to_object<ObjectRefs>(object_address);
5757
assert!(caller_address == object::owner(object), E_NOT_OBJECT_OWNER);
5858
```
5959

60-
## Deploy & Test
60+
## Deploy & Run
61+
62+
| | |
63+
|---|---|
64+
| **Package** | `snippets/design-patterns/autonomous-objects` |
65+
| **Named address** | `deploy_address` |
66+
67+
### Deploy
6168

6269
```bash
6370
aptos move publish --named-addresses deploy_address=default --package-dir snippets/design-patterns/autonomous-objects

snippets/error-codes/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,25 @@ const E_USEFUL_ERROR: u64 = 2;
3535
const E_ERROR_WITHOUT_MESSAGE: u64 = 1;
3636
```
3737

38-
## Deploy & Test
38+
## Deploy & Run
39+
40+
| | |
41+
|---|---|
42+
| **Package** | `snippets/error-codes` |
43+
| **Named address** | `deploy_addr` |
44+
45+
### Deploy
3946

4047
```bash
4148
aptos move publish --named-addresses deploy_addr=default --package-dir snippets/error-codes
4249
```
4350

51+
### Tests
52+
53+
```bash
54+
aptos move test --dev --package-dir snippets/error-codes
55+
```
56+
4457
## Related Examples
4558

4659
- [Private vs Public](../private-vs-public/) -- Uses error codes for access control checks

snippets/fa-lockup-example/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,23 @@ match (&Escrow[escrow_address]) {
5959
};
6060
```
6161

62-
## Running Tests
62+
## Deploy & Run
63+
64+
| | |
65+
|---|---|
66+
| **Package** | `snippets/fa-lockup-example` |
67+
| **Named address** | `lockup_deployer` |
68+
69+
### Deploy
6370

6471
```bash
65-
aptos move test --move-2 --dev --package-dir snippets/fa-lockup-example
72+
aptos move publish --named-addresses lockup_deployer=default --package-dir snippets/fa-lockup-example
6673
```
6774

68-
## Deploy
75+
### Tests
6976

7077
```bash
71-
aptos move publish --named-addresses lockup_deployer=default --package-dir snippets/fa-lockup-example
78+
aptos move test --dev --package-dir snippets/fa-lockup-example
7279
```
7380

7481
## Related Examples

snippets/fractional-token/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,27 @@ Advanced
5454
- The fungible asset metadata object persists forever (even after recombination), but no tokens will exist
5555
- Only the holder of ALL shares can recombine
5656

57-
## Running Tests
57+
## Deploy & Run
58+
59+
| | |
60+
|---|---|
61+
| **Package** | `snippets/fractional-token` |
62+
| **Named address** | `fraction_addr` |
63+
64+
### Deploy
5865

5966
```bash
60-
aptos move test --dev --package-dir snippets/fractional-token
67+
aptos move publish --named-addresses fraction_addr=default --package-dir snippets/fractional-token
6168
```
6269

63-
## Deploy
70+
### Tests
6471

6572
```bash
66-
aptos move publish --named-addresses fraction_addr=default --package-dir snippets/fractional-token
73+
aptos move test --named-addresses fraction_addr=0x1337,minter=0x2337 --package-dir snippets/fractional-token
6774
```
6875

76+
> **Note:** Tests require explicit named addresses because of a dev-dependency constraint on `TokenMinter`.
77+
6978
## Related Examples
7079

7180
- [Liquid NFTs](../liquid-nfts/) -- Pool-based NFT liquidity (many NFTs, shared fungible token)

0 commit comments

Comments
 (0)