Introduction to TELA
Core Concepts

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

PropertyPurposeExample
DocTypeFile type identifier"HTML", "JS", "CSS"
CodeActual file contentYour HTML/JS/CSS code
SubDirFile path/location"/assets/", "/js/"
SCIDUnique contract IDabc123def456...
AuthorDERO wallet addressdeto1qy...
DURLHuman-readable name"myapp-homepage"
SignatureCryptographic proofHash for verification
HeadersMetadataName, 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

PropertyPurposeExample
SCIDUnique contract IDxyz789abc123...
AuthorDERO wallet addressdeto1qy...
DURLApp identifier"my-awesome-app"
DOCsList of DOC SCIDs[abc..., def..., ghi...]
HeadersApp metadataName, 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 locally

One 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 SCID

Enhanced Headers (v2):

"var_header_name"         // Updatable name (with TELA-MOD-1)
"var_header_description"  // Updatable description  
"var_header_icon"         // Updatable icon

TELA-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 needed

Header Version Evolution

Why Two Header Versions?

VersionPrefixMutabilityUse Case
v1nameHdrImmutableSet at deployment only
v2var_header_nameMutableCan 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 SetVar

Best 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 signature

These ensure the code in the DOC hasn't been tampered with.


Key Benefits

BenefitHow DOC/INDEX Achieves It
🔒 SecurityDOC immutability = Code cannot be tampered with
🔄 FlexibilityINDEX updateability = Apps can evolve without redeploying all files
📦 ModularityReusable DOC contracts = Share libraries across apps
🌐 DecentralizationStored on blockchain = No servers, no takedowns
✅ VerificationCryptographic signatures = Users verify authenticity
📜 Version ControlImmutable blockchain = Permanent record of all versions
⚡ PerformanceLocal execution = Fast, no server latency

DOC vs INDEX Comparison

AspectDOC ContractINDEX Contract
Mutability🔒 Immutable (forever locked)✏️ Updateable (can modify)
ContainsSingle file (HTML, JS, CSS)References to DOC contracts
Size Limit18KB per contract~11KB total
PurposeStore actual codeOrganize code into apps
DeploymentDeploy once per fileUpdate to change app structure
Reusability✅ Can be shared across apps❌ App-specific
AnalogyIndividual source filespackage.json or index.html

Real-World Example

Building a Simple Calculator App:

StepWhat You DoContract TypeResult
WriteCreate calculator.html(not deployed yet)Local file
WriteCreate calculator.js(not deployed yet)Local file
WriteCreate styles.css(not deployed yet)Local file
DeployUpload calculator.htmlDOC ContractSCID: aaa111...
DeployUpload calculator.jsDOC ContractSCID: bbb222...
DeployUpload styles.cssDOC ContractSCID: ccc333...
CreateMake INDEX referencing aboveINDEX ContractSCID: xyz999...
ShareGive 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 TypeContent LimitTotal SizeBest Practice
DOC Contract18.00 KB19.20 KB (with headers)Keep files small, split if needed
INDEX Contract~11.64 KBVariableStay 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:

ScenarioWithout SeparationWith DOC/INDEX
Fix a typoRedeploy entire appJust update INDEX to point to new DOC
Add a featureRedeploy everythingDeploy new DOC, update INDEX
Share codeCopy/paste between projectsReference same DOC in multiple INDEXes
Version controlManual trackingBlockchain provides automatic history
Security auditTrust the developerVerify 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:

Build with TELA:

Technical Reference: