Skip to content

tetcore/tetcore-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Tetcore Node Template

A fresh FABRIC-based Tetcore node, ready for hacking 🚀

Overview

This is a minimal Tetcore node template for rapid blockchain prototyping. It provides a foundation for building custom blockchains based on the Tetcore framework.

Quick Start

Build

cargo build --release

Run

# Start a development chain
./target/release/tetcore-node-template --dev

# Purge dev chain
./target/release/tetcore-node-template purge-chain --dev

Project Structure

tetcore-node-template/
├── Cargo.toml           # Workspace root
├── node/                # Node binary
│   ├── Cargo.toml
│   └── src/main.rs
├── runtime/             # Runtime (state transition function)
│   ├── Cargo.toml
│   └── src/lib.rs
└── modules/template/    # Sample module
    ├── Cargo.toml
    └── src/lib.rs

Node

The node directory contains the blockchain node implementation:

  • chain_spec.rs - Chain specification (genesis configuration)
  • service.rs - Node service implementation
  • main.rs - Binary entry point

Chain Specification

Define your chain's initial state in chain_spec.rs:

  • Boot nodes
  • Protocol ID
  • Token properties (symbol, decimals)
  • Genesis accounts and balances

Runtime

The runtime is the core logic that validates transactions and executes state changes.

Key Concepts

  • Transaction: Replaces "Extrinsic" - a unit of work submitted to the network
  • Module: Replaces "Pallet" - a modular runtime component
  • Fabric: Replaces "FRAME" - the framework for building runtimes

Modules

Add custom modules to extend functionality:

pub trait Config {
    type AccountId;
    type Event;
    type Call;
}

Modules (Template)

A sample module demonstrating the module structure.

Creating a Custom Module

  1. Create modules/my-module/src/lib.rs:
use serde::{Deserialize, Serialize};

pub struct Module<T: Config> {
    _config: std::marker::PhantomData<T>,
}

pub trait Config {
    type AccountId;
}
  1. Add to runtime/Cargo.toml:
my-module = { path = "../modules/my-module" }
  1. Include in runtime.

Extending the Template

Adding Custom Transaction Types

#[derive(Serialize, Deserialize)]
pub enum Transaction {
    Transfer { to: AccountId, value: Balance },
    Custom { call: Call },
}

Adding Module Storage

#[storage]
pub struct StorageMap<T: Config> {
    _data: std::marker::PhantomData<T>,
}

Documentation

License

MIT License - see LICENSE file for details.

About

A fresh Tetcore node, ready for hacking 🚀

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages