TSN Documentation

Everything you need to run, mine, and build on Trust Stack Network.

TSN v2.1.5 — Testnet

Getting Started

TSN (Trust Stack Network) is a post-quantum, privacy-first blockchain built in Rust. Transactions are shielded by default using zero-knowledge proofs, and all cryptography is quantum-resistant.

System Requirements

💻
OS
Ubuntu 22.04+
Rust
1.75+ (stable)
💾
RAM
4 GB+
🗃
Disk
50 GB SSD

Quick Start

1

Install Rust

bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
2

Clone & Build

bash
git clone https://github.com/trusts-stack-network/trust-stack-network.git
cd trust-stack-network
cargo build --release
3

Run your node

bash
./target/release/tsn --data-dir ~/.tsn

Your node will start syncing with the network. The RPC API will be available at http://localhost:9333.

Tip: Use --help to see all available CLI options.

Run a Node

Full Node

A full node validates all transactions and blocks, stores the complete blockchain history, and participates in block propagation.

bash
./target/release/tsn \
    --data-dir ~/.tsn \
    --port 9333 \
    --seeds http://seed1.tsnchain.com:9333,http://seed2.tsnchain.com:9333

Configuration

Flag / Env Variable Default Description
--port / TSN_PORT 9333 RPC and P2P listen port
--data-dir / TSN_DATA_DIR ~/.tsn Blockchain data storage directory
--seeds / TSN_SEEDS Built-in seeds Comma-separated list of seed node URLs
--mining-address / TSN_MINING_ADDRESS None Public key for mining rewards (enables mining)
--log-level / TSN_LOG_LEVEL info Log verbosity: error, warn, info, debug, trace
--role / TSN_ROLE full Node role: full, miner, relay, or light

Multi-Role Nodes

TSN supports 3 specialized node roles via the --role CLI flag. Each role optimizes resource usage for its specific function in the network:

⛏️ Miner Node --role miner

Full node with Poseidon2 proof-of-work mining. Validates transactions, produces blocks. Must register a MIK (Miner Identity Key) on-chain. Earns 85% of block reward (42.5 TSN/block). Default role.

🔄 Relay Node --role relay

Full node that stores the complete chain and relays blocks/transactions via gossip protocol. Backbone of the network. Serves fast-sync snapshots for new nodes. Earns from the 8% relay pool.

📱 Light Client --role light

Minimal node that syncs headers only and verifies transactions via ZK proofs. For mobile and constrained devices. No full chain storage. No reward.

Type Full Chain Mines Relays Reward
Miner 85% block reward
Relay 8% relay pool
Light Client
bash
# Run as a miner node (default)
./target/release/tsn --role miner --mining-address YOUR_ADDRESS --data-dir ~/.tsn --port 9333

# Run as a relay node
./target/release/tsn --role relay --data-dir ~/.tsn --port 9333

# Run as a light client
./target/release/tsn --role light --data-dir ~/.tsn --port 9333

Connect to Seed Nodes

Seed nodes help your node discover other peers on the network. TSN uses a Kademlia DHT for peer discovery after initial bootstrap.

seed-1
seed1.tsnchain.com:9333
EU West
seed-2
seed2.tsnchain.com:9333
EU Central
seed-3
seed3.tsnchain.com:9333
EU East
seed-4
seed4.tsnchain.com:9333
EU North

Docker Coming Soon

bash
docker run -d --name tsn-node \
    -p 9333:9333 \
    -v tsn-data:/root/.tsn \
    ghcr.io/trusts-stack-network/tsn:latest

Mining

TSN uses Proof of Work with the Poseidon2 hash function over the Goldilocks field. Mining is deliberately ASIC-resistant and ZK-proof friendly.

Start Mining

To mine, you need a wallet address. Start your node with the --mining-address flag:

bash
./target/release/tsn \
    --data-dir ~/.tsn \
    --mining-address YOUR_PUBLIC_KEY \
    --seeds http://seed1.tsnchain.com:9333

Mining Parameters

Parameter Value
Algorithm Poseidon2 (Goldilocks field)
Block Time ~10 seconds
Block Reward 50 TSN (47.5 miner + 2.5 dev fee)
Dev Fee 5%
Difficulty Adjustment Every 72 blocks
No premine: Every TSN in existence has been mined. The 5% dev fee is the only funding mechanism for ongoing development and is fully transparent on-chain.

Understanding Hashrate

Why is TSN hashrate higher than Monero?

TSN uses Poseidon2, a ZK-native algebraic hash that is computationally lighter per operation than RandomX (Monero) or SHA-256 (Bitcoin). A typical CPU achieves 50-150 KH/s on TSN vs 1-10 KH/s on Monero.

This does NOT mean TSN is less secure. Each hash function has different work-per-hash. Difficulty adjusts automatically to maintain 10-second blocks. Numbers are not comparable across blockchains.

HashBlockchainCPU HashrateDesign
SHA-256Bitcoin20-50 MH/sSimple, ASIC-dominated
RandomXMonero1-10 KH/sCPU-hard, anti-ASIC
Poseidon2TSN50-150 KH/sZK-native, post-quantum

Network hashrate = sum(difficulty) / time_span over 120 blocks (Bitcoin standard).

Monitor Mining

Check your mining stats via the API:

bash
curl http://localhost:9333/miner/stats

🔑 Wallet

TSN wallets use ML-DSA-65 (NIST FIPS 204) post-quantum signatures with BIP39 mnemonic recovery. Your keys are safe against both classical and quantum attacks, and can be restored from a 24-word seed phrase.

Generate a Wallet

bash
# Create a new wallet
./tsn new-wallet --output wallet.json
# The terminal displays 24 words -- WRITE THEM DOWN!

This generates a new ML-DSA-65 key pair with a BIP39 mnemonic seed phrase and saves it to a wallet file. Your public key is your wallet address.

Critical: The 24-word seed phrase displayed during wallet creation is the ONLY way to restore your wallet. Write it down on paper, store it in a safe place. Never store it digitally, never share it with anyone.

Restore from Seed Phrase

If you lose your wallet file, you can restore it using your 24-word seed phrase:

bash
# Restore wallet from seed phrase
./tsn restore-wallet --seed "word1 word2 ... word24" --output wallet.json

# Check your balance
./tsn balance --wallet wallet.json

Key Features

Post-Quantum Safe

ML-DSA-65 (FIPS 204) signatures. Resistant to Shor's algorithm and all known quantum attacks.

BIP39 Recovery

24-word seed phrase backup. Restore your wallet anywhere with just your mnemonic.

Privacy by Default

Shielded balances using ZK proofs. Only you (with your viewing key) can see your balance.

Zero-Knowledge Transfers

Send TSN without revealing amounts. Plonky3 STARKs prove transaction validity without exposing data.

Viewing Key Export & Import

Viewing keys allow you to share read-only access to your shielded balance without exposing your spending key. Useful for auditors, tax reporting, or watch-only wallets.

bash
# Export your viewing key
./target/release/tsn wallet export-viewing-key --output viewing_key.json

# Import a viewing key (watch-only)
./target/release/tsn wallet import-viewing-key --input viewing_key.json
Note: A viewing key can only read balances and transaction history. It cannot sign or send transactions.

Send a Transaction

bash
curl -X POST http://localhost:9333/tx/v2 \
    -H "Content-Type: application/json" \
    -d '{
        "from": "YOUR_PUBLIC_KEY",
        "to": "RECIPIENT_PUBLIC_KEY",
        "amount": 10000000000,
        "signature": "..."
    }'

Amounts are in base units. 1 TSN = 1,000,000,000 base units.

Backup & Restore

Important: Your wallet can be restored from your 24-word BIP39 seed phrase. This is the safest and recommended backup method. Write it on paper, store it offline. If you lose both your wallet file and seed phrase, your funds are unrecoverable.
bash
# Option 1: Restore from seed phrase (recommended)
./tsn restore-wallet --seed "word1 word2 ... word24" --output wallet.json

# Option 2: File backup
cp -r ~/.tsn/wallet/ ~/tsn-wallet-backup/

# Option 2: File restore
cp -r ~/tsn-wallet-backup/ ~/.tsn/wallet/

v2.1.5 CLI Commands

TSN v2.1.5 introduces a unified CLI with interactive menus and new commands:

bash
# Interactive wallet menu (generate, restore, send, receive, history)
./bin/tsn wallet

# Start mining with 2 threads
./bin/tsn miner -t 2

# View transaction history
./bin/tsn history

# Check version, build info, and feature flags
./bin/tsn --version

Auto-Update

TSN nodes automatically detect and install new versions. When a peer announces a newer version during the P2P handshake, your node downloads the update from GitHub (or tsnchain.com fallback), verifies the SHA256 checksum, backs up the current binary, and restarts with the new version.

./tsn update    # Manual update check

⚠️ TSN tokens currently have no monetary value. This is a development testnet. Tokens can be mined for free.


🔌 API Reference

#128268;
API Reference

TSN exposes a RESTful JSON API on the same port as the node (default 9333). Rate limited to prevent abuse.

Base URL: http://localhost:9333

Blockchain

GET /chain/info Get blockchain status and latest block info

Returns the current chain height, latest block hash, difficulty, and node version.

curl
bash
curl http://localhost:9333/chain/info
Response
json
{
    "height": 14523,
    "best_hash": "a1b2c3d4e5f6...abc123",
    "difficulty": "0000ffff00000000...",
    "version": "1.0.0",
    "peers": 12,
    "mempool_size": 3
}
GET /block/:hash Get a block by its hash

Retrieve a full block including header, transactions, and proof-of-work data.

curl
bash
curl http://localhost:9333/block/a1b2c3d4e5f6abc123
GET /block/height/:h Get a block by height
curl
bash
curl http://localhost:9333/block/height/1000

Transactions

POST /tx Submit a V1 transaction

Submit a signed V1 transaction to the mempool.

curl
bash
curl -X POST http://localhost:9333/tx \
    -H "Content-Type: application/json" \
    -d '{"from":"...","to":"...","amount":50000000000,"signature":"..."}'
POST /tx/v2 Submit a shielded V2 transaction

Submit a shielded transaction with ZK proof. Amounts are hidden from the network.

curl
bash
curl -X POST http://localhost:9333/tx/v2 \
    -H "Content-Type: application/json" \
    -d '{
        "from": "YOUR_PUBLIC_KEY",
        "to": "RECIPIENT_PUBLIC_KEY",
        "amount": 10000000000,
        "signature": "..."
    }'
GET /tx/:hash Get transaction by hash
curl
bash
curl http://localhost:9333/tx/a1b2c3d4...
GET /transactions/recent Get recent transactions

Returns the most recent transactions from the mempool and recent blocks.

curl
bash
curl http://localhost:9333/transactions/recent

Network

GET /peers List connected peers
curl
bash
curl http://localhost:9333/peers
Response
json
{
    "peers": [
        {"node_id": "a1b2c3...", "addr": "seed2.tsnchain.com:9333", "latency_ms": 12},
        {"node_id": "d4e5f6...", "addr": "seed3.tsnchain.com:9333", "latency_ms": 8}
    ],
    "count": 2
}
POST /peers Add a peer manually
curl
bash
curl -X POST http://localhost:9333/peers \
    -H "Content-Type: application/json" \
    -d '{"addr": "seed2.tsnchain.com:9333"}'
GET /mempool View pending transactions

Returns all pending transactions waiting to be included in a block. Includes double-spend detection.

curl
bash
curl http://localhost:9333/mempool
GET /sync/status Check sync status
curl
bash
curl http://localhost:9333/sync/status
Response
json
{
    "synced": true,
    "local_height": 14523,
    "network_height": 14523,
    "peers_syncing": 0
}

Mining

GET /miner/stats Get mining statistics
curl
bash
curl http://localhost:9333/miner/stats
Response
json
{
    "mining": true,
    "hashrate": "1.2 MH/s",
    "blocks_mined": 42,
    "total_reward": "2100 TSN",
    "current_difficulty": "0000ffff..."
}

🌐 Network

TSN uses a Kademlia-based P2P network with gossip protocol for block and transaction propagation.

Protocol Details

Property Value
Protocol TSN v1.0
Default Port 9333
Discovery Kademlia DHT (k=20)
Block Propagation Gossip protocol (epidemic)
Node Identity Poseidon2 hash of SLH-DSA public key
Transport HTTP/JSON with rate limiting

Seed Nodes

The testnet currently runs 4 seed nodes across Europe. Connect to any of them to bootstrap your node.

bash
./target/release/tsn --seeds \
    http://seed1.tsnchain.com:9333,\
    http://seed2.tsnchain.com:9333,\
    http://seed3.tsnchain.com:9333,\
    http://seed4.tsnchain.com:9333

🛠 Architecture

TSN is a modular blockchain built entirely in Rust. Every layer is designed for post-quantum security and privacy.

                     TSN Blockchain
          +---------------------------------+
          |          REST API (Axum)         |  <-- Port 9333
          +---------+-----------+-----------+
                    |           |           |
          +---------+  +-------+-------+  ++---------+
          | Mempool |  |   Consensus   |  | P2P Net  |
          | (pool)  |  | PoW+Poseidon2 |  | Kademlia |
          +----+----+  +-------+-------+  +----+-----+
               |               |               |
          +----+---------------+---------------+----+
          |              Core Engine                 |
          |   Blocks | Transactions | State (UTXO)  |
          +-----+----------+----------+-------------+
                |          |          |
          +-----+--+  +---+----+  +--+------+
          | Storage |  | Crypto |  | Wallet  |
          |  (Sled) |  | ML-DSA |  | ML-DSA  |
          |         |  | SLH-DSA|  | Shielded|
          +---------+  | Plonky3|  +---------+
                       +--------+

Cryptography Stack

ML-DSA-65 Post-Quantum

NIST FIPS 204. Lattice-based digital signatures for wallet keys and transaction signing.

SLH-DSA Post-Quantum

NIST FIPS 205. Hash-based signatures for node identity. 32-byte keys, 7.8 KB signatures.

Plonky3 STARKs Post-Quantum

AIR-based FRI STARKs for shielded transactions. No trusted setup required. Quantum-resistant proofs.

Component Technology Purpose
Signatures ML-DSA-65 + SLH-DSA Transaction signing & node identity
Hashing Poseidon2 (Goldilocks) ZK-friendly hashing, PoW mining
ZK Proofs Plonky3 STARKs Shielded transactions, private balances
Consensus PoW (Poseidon2) Block production, 72-block difficulty adjustment
Storage Sled (embedded) Block & state persistence, UTXO set
Network Kademlia DHT Peer discovery, gossip propagation

Synchronization & Anti-Fork

Fast-Sync Protocol v0.4.0

New nodes download a gzip-compressed state snapshot from any peer via /snapshot/download, then sync only missing blocks. Join the network in under 5 minutes instead of hours.

Heaviest Chain Rule

Fork choice based on cumulative proof-of-work (sum of all block difficulties), not longest chain. Prevents low-difficulty spam attacks — same approach as Bitcoin Core.

Checkpoint Finality

Every 100 blocks, a checkpoint is established. No chain reorganization is permitted beyond the latest checkpoint, providing deterministic finality.

Protection Description
Heaviest chain Fork choice = cumulative work, not height
MAX_REORG_DEPTH = 100 Hard limit — no reorg deeper than 100 blocks
Checkpoint finality Every 100 blocks, immutable checkpoint
Anti-Fork Sync Gate Miners must be within 2 blocks of tip to mine
Genesis verification All nodes verify genesis hash at startup
Fast-Sync Snapshot download + sync missing blocks (< 5 min)
Deep dive: For the full technical specification, read the Whitepaper.

TSN Documentation — Trust Stack Network