Logo
Registry

lang_tour

@example

• v1.0.0

Comprehensive tutorial showcasing TX3 programming language features

TX3 Language Tour

A comprehensive tutorial protocol that showcases the full spectrum of TX3 programming language features through practical examples. This protocol serves as a guided tour through TX3's type system, data structures, and transaction modeling capabilities.

Features

  • Rich Type System: Demonstrates record types, variant types, and complex data structures
  • Asset Management: Shows both static and dynamic asset definitions
  • Policy Integration: Examples of hash-based and fully-defined policies
  • Transaction Modeling: Complete transaction structure with inputs, outputs, and metadata
  • Data Manipulation: Field spreading, list operations, and datum transformations

Language Elements Demonstrated

Type Definitions

  • MyRecord: Complex record type with multiple field types (Int, Bytes, List<Int>)
  • MyVariant: Union type with multiple cases and optional fields
  • OutputReference: Nested type structures for blockchain references

Asset and Policy Examples

  • OnlyHashPolicy: Simple hash-based policy definition
  • StaticAsset: Fixed asset with predefined policy and token name
  • FullyDefinedPolicy: Complete policy with hash, script, and reference
  • AnyAsset: Dynamic asset creation with runtime parameters

Transaction Features

  • Input Validation: Datum type checking and minimum amount requirements
  • Redeemer Usage: Complex redeemer structures with field references
  • Asset Minting: Both static and dynamic token minting examples
  • Output Construction: Field spreading and datum transformation
  • Validity Windows: Time-based transaction validity constraints
  • Metadata Integration: Custom metadata attachment

Educational Progression

  1. Basic Types: Start with simple record and variant definitions
  2. Asset Concepts: Learn asset and policy declaration patterns
  3. Transaction Structure: Understand input/output/mint relationships
  4. Data Flow: Follow how data transforms through the transaction
  5. Advanced Features: Explore field spreading and complex expressions

Parameters

  • quantity: Int - Demonstrates numeric parameters and field references
  • validUntil: Int - Shows time-based validity constraints
  • metadata: Bytes - Illustrates metadata handling

Use Cases

  • Learning TX3: Step-by-step introduction to language features
  • Reference Implementation: Template for common TX3 patterns
  • Development Training: Hands-on examples for protocol developers
  • Feature Testing: Comprehensive coverage of language capabilities
  • Documentation: Living examples of TX3 syntax and semantics

Technical Highlights

  • Field Spreading: ...source syntax for datum field inheritance
  • Cross-Reference: Using input fields in output calculations
  • Type Safety: Compile-time validation of datum types and asset amounts
  • Redeemer Patterns: Complex redeemer construction with variant types

This protocol is essential for anyone learning TX3, providing a comprehensive overview of the language's capabilities through practical, working examples.

lang_tour

Published by

@example

Install

trix install example/lang_tour

Publication datePublished 10 months ago
Back to all Protocols