|
| 1 | +# Example Specs |
| 2 | + |
| 3 | +## Table of Contents |
| 4 | + |
| 5 | +- [Audience](#audience) |
| 6 | +- [README Structure](#readme-structure) |
| 7 | +- [Example README Principles](#example-readme-principles) |
| 8 | +- [Example Code Principles](#example-code-principles) |
| 9 | + |
| 10 | +## Audience |
| 11 | + |
| 12 | +This guide is intended for both: |
| 13 | +- **Developers** maintaining or contributing to `/examples` |
| 14 | +- **Coding agents** (e.g. Cursor, Copilot, GPT) that assist with editing, reviewing, or scaffolding examples |
| 15 | + |
| 16 | +AI agents should be pointed to this file via `AGENTS.md` or `.cursor/rules`. |
| 17 | + |
| 18 | +Currently, this document will only detail the structure for the READMEs of the examples. |
| 19 | + |
| 20 | +## README Structure |
| 21 | + |
| 22 | +1. **Header** |
| 23 | + - Goal: Branding + promote docs site + entrypoint |
| 24 | + - Contents: LayerZero logo + links to docs and dev portal |
| 25 | + |
| 26 | +2. **Example Title** |
| 27 | + - Goal: What the example will teach |
| 28 | + - Contents: Title + 1–2 sentence goal-style description |
| 29 | + |
| 30 | +3. **Table of Contents** |
| 31 | + - Goal: Allow user to easily navigate the README |
| 32 | + - Contents: TOC of all headings |
| 33 | + |
| 34 | +4. **Prerequisite Knowledge** |
| 35 | + - Goal: What to understand before running the example |
| 36 | + - Contents: e.g., What is an OApp? What is an OFT? |
| 37 | + |
| 38 | +5. **Introduction** _(optional)_ |
| 39 | + - Goal: High-level context on what this example covers |
| 40 | + - Contents: Brief explanation; skip if title + prerequisites suffice |
| 41 | + |
| 42 | +6. **Requirements** |
| 43 | + - Goal: What needs to be installed |
| 44 | + - Contents: Tools + versions; optionally call out testnet funding needs |
| 45 | + |
| 46 | +7. **Scaffold this example** |
| 47 | + - Goal: How to initialize the example |
| 48 | + - Contents: `pnpm dlx create-lz-oapp@latest --example <name>` (Some examples require a feature flag. Refer to `packages/create-lz-oapp/src/config.ts` to verify) |
| 49 | + |
| 50 | +8. **Helper Tasks (inline notice)** |
| 51 | + - Goal: Let users know helpers exist |
| 52 | + - Contents: Single-line pointer to helper tasks section |
| 53 | + |
| 54 | +9. **Setup** |
| 55 | + - Goal: What to configure before building |
| 56 | + - Contents: `.env` setup, deployer account prep |
| 57 | + |
| 58 | +10. **Build** |
| 59 | + - Goal: How to compile contracts/programs/modules |
| 60 | + - Contents: Build commands |
| 61 | + |
| 62 | +11. **Deploy** |
| 63 | + - Goal: How to deploy contracts/programs/modules |
| 64 | + - Contents: Deploy command + minting instructions (if applicable) |
| 65 | + |
| 66 | +12. **Enable Messaging** |
| 67 | + - Goal: How to wire/configure OApps for messaging |
| 68 | + - Contents: LZ config, init, and wiring steps |
| 69 | + |
| 70 | +13. **Sending Message/OFT/ONFT** |
| 71 | + - Goal: Trigger a cross-chain action |
| 72 | + - Contents: CLI command to triffer send, both/all directions. E.g. for examples/oft, it is `pnpm hardhat lz:oft:send --src-eid 40232 --dst-eid 40231 --amount 1 --to <EVM_ADDRESS>` |
| 73 | + |
| 74 | +14. **Next Steps** |
| 75 | + - Goal: What to know after completing the deployment |
| 76 | + - Contents: Production Deployment Checklist + links (Security Stack, Message Options) |
| 77 | + |
| 78 | +15. **Production Deployment Checklist** |
| 79 | + - Goal: Prep for production usage |
| 80 | + - Contents: Gas profiling, DVN config, confirmation settings |
| 81 | + |
| 82 | +16. **Appendix** |
| 83 | + - Goal: Mark end of core deployment steps |
| 84 | + - Contents: Additional topics and configuration |
| 85 | + |
| 86 | + 16.1. **Running tests** |
| 87 | + - Goal: How to test contracts/programs |
| 88 | + - Contents: Test commands |
| 89 | + |
| 90 | + 16.2. **Adding other chains** |
| 91 | + - Goal: Expand the example to more networks |
| 92 | + - Contents: Add logic, update `hardhat.config.ts` |
| 93 | + |
| 94 | + 16.3. **Using Multisigs** |
| 95 | + - Goal: Deploy using a multisig wallet |
| 96 | + - Contents: Command param diffs, multi-VM notes |
| 97 | + |
| 98 | + 16.4. **LayerZero Hardhat Helper Tasks (detailed)** |
| 99 | + - Goal: Understand all helper tasks |
| 100 | + - Contents: Link to docs + list of built-in and local tasks |
| 101 | + |
| 102 | + 16.5. **Contract/Program Verification** |
| 103 | + - Goal: Verify deployments |
| 104 | + - Contents: VM-specific verification docs |
| 105 | + |
| 106 | + 16.6. **Troubleshooting** |
| 107 | + - Goal: Resolve errors and setup issues |
| 108 | + - Contents: Link to general troubleshooting + local fixes |
| 109 | + |
| 110 | +Any sections that don't appear in the above list should be considered for removal. |
| 111 | + |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## Example README Principles |
| 116 | + |
| 117 | +1. Example READMEs should focus on required commands, with elaborations linked to docs. |
| 118 | +2. Avoid duplicating explanations of general concepts (e.g., OFTs)—link to docs instead. |
| 119 | +3. The first mention of concepts like Endpoint IDs, Wiring, etc. should link to the glossary: https://docs.layerzero.network/v2/home/glossary |
| 120 | +4. TODO: Every README should invite partners to provide feedback to drive improvements. |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Example Code Principles |
| 125 | + |
| 126 | +1. **Options-first**: Enforced Options implementation and instructions should be included by default (e.g. in `layerzero.config.ts`). |
| 127 | +2. **Two chains only**: Examples should use only 2 chains by default to reduce testnet setup friction; use “Add other chains” section to scale up if needed. |
0 commit comments