Core Concepts: DOC vs INDEX
Think of it like this: DOC contracts are your code files, INDEX contract is your package.json - it tells browsers how to assemble everything!
TELA's dual-contract system enables modular, updatable, secure on-chain applications.
The Two Contract Types
📄 DOC Contract (Code Storage)
What it is: A container for a single file in your TELA app
| Property | Purpose | Example |
|---|---|---|
| DocType | File type identifier | "HTML", "JS", "CSS" |
| Code | Actual file content | Your HTML/JS/CSS code |
| SubDir | File path/location | "/assets/", "/js/" |
| SCID | Unique contract ID | abc123def456... |
| Author | DERO wallet address | deto1qy... |
| DURL | Human-readable name | "myapp-homepage" |
| Signature | Cryptographic proof | Hash for verification |
| Headers | Metadata | Name, description |
Think: Each DOC = One file (like index.html, app.js, etc.)
Key Feature: 🔒 Immutable - Once deployed, code cannot be changed (security!)
📋 INDEX Contract (Application Manifest)
What it is: The "table of contents" that references all your DOC contracts
| Property | Purpose | Example |
|---|---|---|
| SCID | Unique contract ID | xyz789abc123... |
| Author | DERO wallet address | deto1qy... |
| DURL | App identifier | "my-awesome-app" |
| DOCs | List of DOC SCIDs | [abc..., def..., ghi...] |
| Headers | App metadata | Name, description, icon |
Think: INDEX = package.json (tells Engram what files to load)
Key Feature: ✏️ Updateable - Can point to new DOC contracts (flexibility!)
How It Works (Simple Flowchart)
Deployment:
Developer writes code
↓
Deploy index.html → DOC Contract A (immutable)
Deploy app.js → DOC Contract B (immutable)
Deploy style.css → DOC Contract C (immutable)
↓
Create INDEX Contract → References A, B, C
↓
Give users INDEX SCID → They can access your app!User Access:
User enters INDEX SCID into Engram
↓
Engram fetches INDEX from blockchain
↓
INDEX says: "Load DOC A, DOC B, DOC C"
↓
Engram fetches all DOCs from blockchain
↓
Verifies hashes (security check)
↓
Executes app locallyOne SCID opens your entire app!
Headers and Metadata: The ART-NFA Standard
Standard Compatibility: TELA contracts use the ART-NFA Standard (opens in a new tab) header structure for consistent metadata across the DERO ecosystem.
What is ART-NFA?
ART-NFA (Artificer Non-Fungible Assets) is a standardized header system for DERO smart contracts. TELA adopts this standard to ensure:
- Consistency - Same metadata format across all DERO applications
- Interoperability - Tools can parse any ART-NFA compliant contract
- Identification - Easy detection of TELA contracts on the blockchain
- Integration - Seamless compatibility within DERO ecosystem
TELA Header Structure
TELA contracts use these standard headers:
Core Headers (v1):
"nameHdr" // Contract/file name
"descrHdr" // Description
"iconURLHdr" // Icon URL or SCIDEnhanced Headers (v2):
"var_header_name" // Updatable name (with TELA-MOD-1)
"var_header_description" // Updatable description
"var_header_icon" // Updatable iconTELA-Specific Headers
Beyond ART-NFA, TELA adds specialized headers:
"dURL" // TELA decentralized URL (e.g., "myapp.tela")
"docType" // File type (TELA-HTML-1, TELA-JS-1, etc.)
"subDir" // Subdirectory path
"mods" // TELA-MOD-1 tags (e.g., "vsoo,txdwd")
"DOC1" // First DOC SCID (INDEX contracts)
"DOC2" // Second DOC SCID (if exists)
// DOC3, DOC4... as neededHeader Version Evolution
Why Two Header Versions?
| Version | Prefix | Mutability | Use Case |
|---|---|---|---|
| v1 | nameHdr | Immutable | Set at deployment only |
| v2 | var_header_name | Mutable | Can update with TELA-MOD-1 |
Example:
// v1 Headers (immutable)
STORE("nameHdr", "My App") // Cannot change after deployment
// v2 Headers (mutable with TELA-MOD-1)
STORE("var_header_name", "My App") // Can update via SetVarBest Practice: Use v2 headers if you want the ability to update metadata later!
Signature Headers
TELA-DOC contracts include cryptographic signatures for file verification:
"fileCheckC" // C value from DERO signature
"fileCheckS" // S value from DERO signatureThese ensure the code in the DOC hasn't been tampered with.
Key Benefits
| Benefit | How DOC/INDEX Achieves It |
|---|---|
| 🔒 Security | DOC immutability = Code cannot be tampered with |
| 🔄 Flexibility | INDEX updateability = Apps can evolve without redeploying all files |
| 📦 Modularity | Reusable DOC contracts = Share libraries across apps |
| 🌐 Decentralization | Stored on blockchain = No servers, no takedowns |
| ✅ Verification | Cryptographic signatures = Users verify authenticity |
| 📜 Version Control | Immutable blockchain = Permanent record of all versions |
| ⚡ Performance | Local execution = Fast, no server latency |
DOC vs INDEX Comparison
| Aspect | DOC Contract | INDEX Contract |
|---|---|---|
| Mutability | 🔒 Immutable (forever locked) | ✏️ Updateable (can modify) |
| Contains | Single file (HTML, JS, CSS) | References to DOC contracts |
| Size Limit | 18KB per contract | ~11KB total |
| Purpose | Store actual code | Organize code into apps |
| Deployment | Deploy once per file | Update to change app structure |
| Reusability | ✅ Can be shared across apps | ❌ App-specific |
| Analogy | Individual source files | package.json or index.html |
Real-World Example
Building a Simple Calculator App:
| Step | What You Do | Contract Type | Result |
|---|---|---|---|
| Write | Create calculator.html | (not deployed yet) | Local file |
| Write | Create calculator.js | (not deployed yet) | Local file |
| Write | Create styles.css | (not deployed yet) | Local file |
| Deploy | Upload calculator.html | DOC Contract | SCID: aaa111... |
| Deploy | Upload calculator.js | DOC Contract | SCID: bbb222... |
| Deploy | Upload styles.css | DOC Contract | SCID: ccc333... |
| Create | Make INDEX referencing above | INDEX Contract | SCID: xyz999... |
| Share | Give users xyz999... | - | Anyone can use your app! |
Users only need the final INDEX SCID (xyz999...) to access your complete calculator app!
Technical Constraints
Size Limits (Blockchain Constraints):
| Contract Type | Content Limit | Total Size | Best Practice |
|---|---|---|---|
| DOC Contract | 18.00 KB | 19.20 KB (with headers) | Keep files small, split if needed |
| INDEX Contract | ~11.64 KB | Variable | Stay under 9KB for easy updates |
DOC contracts are immutable! Test thoroughly before deploying. To "update" code, deploy a new DOC and update your INDEX to reference it.
Best Practices:
- ✅ Split large files across multiple DOC contracts
- ✅ Organize with SubDir paths (e.g.,
/js/,/css/) - ✅ Modular design - Break into logical components
- ✅ Reusable libraries - Share common DOCs across apps
- ✅ Version control - New features = new DOCs + INDEX update
Why This Design?
The genius of separating DOC and INDEX:
| Scenario | Without Separation | With DOC/INDEX |
|---|---|---|
| Fix a typo | Redeploy entire app | Just update INDEX to point to new DOC |
| Add a feature | Redeploy everything | Deploy new DOC, update INDEX |
| Share code | Copy/paste between projects | Reference same DOC in multiple INDEXes |
| Version control | Manual tracking | Blockchain provides automatic history |
| Security audit | Trust the developer | Verify immutable DOC hashes |
The Bottom Line
DOC + INDEX = Secure + Flexible
DOC Contracts (Immutable)
✅ Security through immutability
✅ Cryptographic verification
✅ Cannot be tampered with
INDEX Contracts (Updateable)
✅ Apps can evolve
✅ Point to new DOCs
✅ Maintain same SCID for users
Result: Best of both worlds!TELA makes blockchain development accessible to web developers while maintaining the security and decentralization benefits of blockchain technology.
Related Pages
Understanding TELA:
- TELA Overview - Platform introduction
- TELA Security Model - How security works
- Content Rating System - Community moderation
Build with TELA:
- Quick Start Tutorial - Deploy your first app
- TELA-CLI Overview - Command-line tools
- Templates - Ready-to-use starting points
Technical Reference:
- API Reference - Complete API docs
- Data Types - DOC and INDEX specifications