Skip to content

71mengr/antdchain

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

164 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ANTDChain - Fast PoW Layer 1 Blockchain with Rotating King Governance

πŸš€ Overview

ANTDChain is a high-performance Proof-of-Work Layer 1 blockchain featuring a unique Rotating King governance system. Built for speed, security, and decentralized governance, it combines Ethereum-compatible tooling with innovative economic models.

✨ Key Features

πŸ—οΈ Technical Architecture

  • Custom PoW Algorithm: BLAKE3 + Argon2id hybrid for ASIC resistance
  • EVM Compatibility: Full Ethereum Virtual Machine support
  • Lightning-Fast Sync: Optimized peer-to-peer synchronization
  • Checkpoint System: Trustless bootstrapping with peer-validated checkpoints
  • Database-Backed State: Persistent storage with automatic recovery

πŸ‘‘ Rotating King Governance

  • Dynamic Royalty System: 5% of block rewards distributed to rotating kings
  • Stake-Based Eligibility: 100,000 ANTD minimum stake requirement
  • Automatic Rotation: Kings rotate every 100 blocks automatically
  • Ineligibility Protection: Addresses below minimum stake auto-removed
  • Network Consensus: King lists synchronized across all nodes

πŸ”§ Core Components

1. Blockchain Engine

  • Multi-threaded block validation
  • Orphan block rejection (no orphan storage)
  • Chain reorganization protection
  • State trie with Merkle proofs
  • Transaction pool with confirmation system

2. P2P Network Layer

  • libp2p-based networking with GossipSub
  • Multi-topic pub/sub for blocks, transactions, and king events
  • DHT-based peer discovery
  • Rate-limited message handling
  • Direct block push optimization

3. Mining System

  • CPU-mining optimized PoW
  • Dynamic difficulty adjustment
  • Mining templates for stratum compatibility
  • Real-time hash rate monitoring

4. Wallet & Transaction System

  • Hierarchical Deterministic (HD) wallets
  • Secure key storage with encryption
  • Transaction signing with ECDSA
  • Nonce management and fee calculation

5. JSON-RPC API

  • Full Ethereum-compatible API
  • eth_, net_, web3_ namespace support
  • Web interface with real-time monitoring
  • Health check endpoints

πŸ“Š Economic Model

Tokenomics

  • Native Token: ANTD (1 ANTD = 10^18 base units)
  • Block Reward: 1 ANTD + transaction fees
  • Reward Distribution:
    • 90% β†’ Miner
    • 5% β†’ Main King (fixed address)
    • 5% β†’ Rotating King (eligible addresses)

Staking Requirements

  • Minimum Stake: 100,000 ANTD for king eligibility
  • Rotation Interval: Every 100 blocks (~50 minutes)
  • Activation Delay: 2 blocks after rotation

πŸ› οΈ Getting Started

Prerequisites

  • Go 1.21+
  • GCC compiler (for CGO)
  • 4GB+ RAM recommended
  • 50GB+ storage for full node

Installation

From Source

# Clone repository
git clone https://github.com/antdaza/antdchain.git
cd antdchain

# Build for Ubuntu
make ubuntu-build

# Or build for your platform
go build -o antdchain ./cmd/antdchain

Quick Start

# Start a node with default settings
./antdchain --data-dir ./antdchain-data --p2p-port 3000

# Start with mining enabled
./antdchain --startmining --miner-address YOUR_ADDRESS

# Connect to testnet
./antdchain --bootstrap "/ip4/1.2.3.4/tcp/3000/p2p/12D3KooW..."

# Open console interface
./antdchain --console

Configuration

Data Directory Structure

antdchain-data/
β”œβ”€β”€ blocks/          # Block storage
β”œβ”€β”€ state/           # Blockchain state
β”œβ”€β”€ wallets/         # Encrypted wallets
β”œβ”€β”€ p2p-key.hex      # Node identity
└── checkpoints.json # Trusted checkpoints

Network Ports

  • P2P: 3000 (default)
  • JSON-RPC: 8089 (default)
  • Web Interface: 8090 (default)

πŸ”Œ API Reference

JSON-RPC Endpoints

# Get chain height
curl -X POST http://localhost:8089/rpc \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

# Get balance
curl -X POST http://localhost:8089/rpc \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x...","latest"],"id":1}'

# Send transaction
curl -X POST http://localhost:8089/rpc \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0x..."],"id":1}'

Web Interface

Access at: http://localhost:8090

  • Real-time block explorer
  • Network status dashboard
  • Wallet management
  • Mining statistics

πŸ‘‘ King Management Commands

# List current kings
./antdchain king list

# Check eligibility status
./antdchain king status

# Force rotate to specific king
./antdchain king rotate --index 2 --reason "maintenance"

# Cleanup ineligible kings
./antdchain king cleanup

# Sync configurations from peers
./antdchain king sync

# Debug king database
./antdchain king debug

πŸ”„ Network Synchronization

Sync Modes

  1. Fast Sync: Downloads blocks sequentially from highest peer
  2. Gossip Sync: Receives blocks via pub/sub (real-time)
  3. Database Sync: Rotating king state synchronization
  4. Config Sync: King list consensus synchronization

Peer Discovery

  • Bootstrap Nodes: Manual configuration
  • mDNS: Local network discovery
  • DHT: Global peer discovery
  • GossipSub: Topic-based peer finding

πŸ”’ Security Features

Node Security

  • Persistent peer identity with encrypted storage
  • Rate limiting per peer (transactions, blocks, events)
  • Checkpoint validation for chain integrity
  • Transaction nonce and signature verification

Wallet Security

  • BIP-39 mnemonic phrases
  • Encrypted keystore (AES-256)
  • Hierarchical deterministic wallets
  • Air-gapped signing support

Network Security

  • Proof-of-Work spam protection
  • Sybil attack resistance via stake requirements
  • Eclipse attack prevention with diverse peer connections
  • Message authentication and encryption

πŸ“ˆ Monitoring & Maintenance

Logging

# View logs in JSON format
tail -f antdchain-data/node.log | jq .

# Monitor sync status
./antdchain --console
> debug sync
> debug peers
> debug kings

Performance Metrics

  • Block propagation time
  • Transaction throughput
  • Network latency
  • Memory usage
  • Database performance

Health Checks

# API health check
curl http://localhost:8089/health

# Check sync status
curl -X POST http://localhost:8089/rpc \
  -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'

πŸ”§ Advanced Configuration

Custom Genesis

{
  "genesis": {
    "miner": "0qANA3c85k94LTyTXLGDdEzmLE32b1qhYZF",
    "timestamp": 1763731821,
    "difficulty": "1",
    "alloc": {
      "0qANA3c85k94LTyTXLGDdEzmLE32b1qhYZF": "1000000000000000000000000"
    }
  }
}

Mining Configuration

# Custom difficulty
./antdchain --mining-difficulty 1000

# Set CPU threads
./antdchain --mining-threads 4

# Target block time
./antdchain --target-block-time 30

P2P Configuration

# Custom bootstrap nodes
./antdchain --bootstrap "/ip4/1.2.3.4/tcp/3000/p2p/...,/ip4/5.6.7.8/tcp/3000/p2p/..."

# Disable discovery
./antdchain --no-mdns --no-dht

# Maximum peers
./antdchain --max-peers 100 --min-peers 10

🚨 Troubleshooting

Common Issues

Node Won't Sync

# Force resync from genesis
rm -rf antdchain-data/blocks/*
rm -rf antdchain-data/state/*

# Check peer connections
./antdchain --console
> debug peers
> force sync

Mining Not Working

# Check miner address
./antdchain --console
> get miner

# Verify PoW difficulty
> debug pow

# Check block template
> debug mining

King List Issues

# Force config sync
./antdchain king sync

# Clean ineligible kings
./antdchain king cleanup

# Reset to defaults
rm -rf antdchain-data/kingdb/*

Database Corruption

# Create backup
./antdchain king backup ./king-backup

# Restore from backup
cp -r ./king-backup/* antdchain-data/kingdb/

🀝 Contributing

Development Setup

# Clone with submodules
git clone --recursive https://github.com/antdaza/antdchain.git

# Install dependencies
go mod download

# Run tests
go test ./...

# Build development version
make dev-build

Code Structure

antdchain/
β”œβ”€β”€ cmd/antdchain/          # Main executable
β”œβ”€β”€ antdc/                  # Core blockchain implementation
β”‚   β”œβ”€β”€ chain/            # Blockchain logic
β”‚   β”œβ”€β”€ p2p/              # Network layer
β”‚   β”œβ”€β”€ mining/           # PoW implementation
β”‚   β”œβ”€β”€ tx/               # Transaction system
β”‚   β”œβ”€β”€ wallet/           # Wallet management
β”‚   β”œβ”€β”€ rotatingking/     # King governance
β”‚   └── vm/               # EVM implementation
β”œβ”€β”€ console/              # Interactive console
└── web/                  # Web interface

Testing

# Run unit tests
go test ./antdc/...

# Run integration tests
go test -tags=integration ./...

# Benchmark performance
go test -bench=. ./antdc/chain/...

πŸ“š Documentation

Further Reading

Community

πŸ“„ License

antdchain is released under the MIT License. See LICENSE for details.

πŸ™ Acknowledgments

  • Ethereum Foundation for EVM specification
  • libp2p team for networking stack
  • Go Ethereum for inspiration and tooling
  • All contributors and testers

Disclaimer: ANTDChain is experimental software. Use at your own risk. Always backup your wallets and private keys.

Version: v1.0.0 - December 2025

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 96.6%
  • JavaScript 1.8%
  • Other 1.6%