What works:
- ✅ LLM inference for proof of AI (real llama.cpp integration)
- ✅ Deterministic LLM inference with nonce-based mining
- ✅ Node daemon
poaidwith CLI commands - ✅ P2P networking with libp2p
- ✅ Procedural quiz generation for mining datasets (dynamic, verifiable Q&A without external files)
- ✅ Block mining and validation using LLM outputs
- ✅ Bitcoin-style difficulty retargeting with compact bits
- ✅ Local testnet with multiple nodes syncing chains and competing for blocks
- ✅ Key generation and management for mining rewards
- ✅ Ethereum-compatible addresses for block subsidies
- ✅ Wallet system with balance checking
- ✅ Transaction creation and signing
- ✅ Secure cryptographic transfers between addresses
What doesn't work yet:
- ❌ Transaction broadcasting and mempool integration
- ❌ On-chain governance (deprecated; procedural generation handles datasets)
- ❌ Full EVM compatibility for smart contracts
- ❌ Advanced features like staking or AI model upgrades
Check repo traffic trends: Traffic Graphs
PoAI is a blockchain protocol that replaces traditional Proof of Work (PoW) with Proof of AI (PoAI), where miners perform verifiable forward passes on large language models (LLMs) to generate blocks. This leverages AI computation for consensus, making mining useful for AI training/inference while maintaining security. Datasets for inference are now procedurally generated (e.g., dynamic math quizzes), ensuring determinism and eliminating the need for curated datasets or on-chain governance.
Traditional blockchains like Bitcoin use energy-intensive hashing for PoW. PoAI shifts this to AI workloads: Miners run inference on procedural quizzes using a fixed model (e.g., TinyLlama-1.1B), and valid outputs (meeting difficulty targets) create blocks. Rewards (subsidies) are earned automatically on successful mines. The chain is EVM-compatible in design, with future support for transactions and contracts.
Why now? With GGUF models and go-llama.cpp, deterministic AI proofs are feasible locally. This repo implements the core node in Go.
Want to get mining quickly? Here's the complete workflow:
# 1. Clone and setup
git clone https://github.com/Deep-Commit/poai.git
cd poai
git submodule update --init --recursive
# 2. Build the daemon (with real LLM support)
brew install llama.cpp # macOS
# OR
sudo apt install llama-cpp # Ubuntu/Debian
go build -tags llama -o poaid cmd/poaid/*.go
# Alternative for Linux (if shell expansion fails):
# go build -tags llama -o poaid cmd/poaid/main.go cmd/poaid/cli.go
# 3. Generate mining keys
./scripts/generate_keys.sh
# 4. Set your Hugging Face token (required for model download)
export HF_TOKEN=hf_XXXX # Get from https://huggingface.co/settings/tokens
# 5. Start mining! (automatically downloads model)
./scripts/start_mining.sh
# Or manually:
# ./poaid --miner-address=$(cat keys/poai_address.txt) \
# --model-path=models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf \
# --target=500 \
# --data-dir=data1 \
# --p2p-port=4001That's it! You're now mining PoAI blocks and earning rewards. See the detailed setup instructions below for more options.
Clone the repo and initialize submodules:
git clone https://github.com/Deep-Commit/poai.git
cd poai
git submodule update --init --recursive # Initializes go-llama.cpp submoduleImportant: Directory Check
Ensure you are in the repository root directory before running any build or run commands. Run ls to verify—you should see files and directories like go.mod, go.sum, core/, cmd/, README.md, etc. If you see something else (e.g., a nested poai/ subdir), you may have cloned into an existing directory—delete and re-clone into a clean location. Running commands outside the root will cause errors like "go.mod file not found".
- Go 1.21+ installed.
- A C compiler (e.g., clang or gcc).
- Hardware: CPU is sufficient (use
--gpu-layers=0); GPU optional for acceleration (e.g., Metal on macOS, CUDA on Linux/Windows). - Disk space: ~1GB for models and data directories.
PoAI uses the TinyLlama-1.1B-Chat-v1.0 GGUF model for deterministic inference. Note: Hugging Face may require a free account and access token for command-line downloads due to Git LFS restrictions. Do not commit models to the repo.
Create a models directory:
mkdir -p modelscurl -L -o models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_K_M.ggufNote: This will likely fail due to Hugging Face's authentication requirements. Use Option 2 or 3 instead.
- Sign up for a free Hugging Face account at https://huggingface.co/join.
- Create an access token (Read role) at https://huggingface.co/settings/tokens.
- Replace
hf_XXXXwith your token and run:
curl -L -H "Authorization: Bearer hf_XXXX" -o models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf- Install the CLI (requires Python 3.8+ and pip):
pip install -U huggingface_hub- Log in (paste your access token when prompted):
huggingface-cli login- Download:
huggingface-cli download TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf --local-dir modelsVerify the download: The file should be ~669MB. Update the --model-path flag in node commands to models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf.
Ensure you're in the repo root (check with ls as above).
This builds with real LLM inference using llama.cpp. Requires llama-cpp to be installed:
# Install llama.cpp first
brew install llama.cpp
# Build with real LLM support
go build -tags llama -o poaid cmd/poaid/*.goThis builds with stub LLM for fast testing without LLM dependencies:
# Build with stub LLM (no external dependencies)
go build -o poaid cmd/poaid/*.goFor macOS with Metal GPU acceleration:
CGO_LDFLAGS="-framework Metal -framework Foundation" go build -tags llama -o poaid cmd/poaid/*.goNote: The cmd/poaid/*.go pattern includes all Go files in the cmd/poaid directory (main.go and cli.go).
If you encounter "go.mod not found", double-check your directory—you must be in the root where go.mod exists.
Before starting to mine, you need to generate a keypair to receive block rewards. PoAI uses Ethereum-compatible addresses for mining rewards.
# Make the script executable and run it
chmod +x scripts/generate_keys.sh
./scripts/generate_keys.shThis will:
- Generate a new keypair
- Save the private key to
keys/poai_private_key.txt(secure) - Save the address to
keys/poai_address.txt - Create a miner config file with usage examples
# Generate keys and display them
./poaid generate-key
# Generate keys and save to files
./poaid generate-key --save --output-dir=./keysIf you prefer to generate keys manually using standard tools:
# Using OpenSSL (if available)
openssl ecparam -genkey -name secp256k1 -out private.pem
openssl ec -in private.pem -pubout -out public.pem
# Convert to hex format (you'll need to implement this conversion)
# The address is the last 20 bytes of the Keccak256 hash of the public keyThis sets up a local blockchain with LLM-based mining on procedurally generated quizzes. Use --target=500 for easier mining (lower values = harder difficulty; adjusts automatically like Bitcoin). Run all commands from the repo root.
Note: Procedural quiz generation is enabled by default. If you want to use a test corpus instead, add --test-corpus=./dataset/testdata to the commands below.
Pro Tip: Use ./scripts/start_mining.sh to automatically download the model and start mining with your generated keys.
# If you used the key generation script
./poaid --model-path=models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf \
--gpu-layers=0 \
--data-dir=data1 \
--p2p-port=4001 \
--target=500 \
--miner-address=$(cat keys/poai_address.txt)Or manually specify the address:
./poaid --model-path=models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf \
--gpu-layers=0 \
--data-dir=data1 \
--p2p-port=4001 \
--target=500 \
--miner-address=YOUR_GENERATED_ADDRESS_HERE- Note the peer ID from logs (e.g.,
/ip4/127.0.0.1/tcp/4001/p2p/<PEER_ID>).
Replace <PEER_ID_FROM_NODE_1> with the actual ID and use a different mining address:
# Generate a second keypair for node 2
./poaid generate-key --save --output-dir=./keys2
# Start node 2 with the new address
./poaid --model-path=models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf \
--gpu-layers=0 \
--data-dir=data2 \
--p2p-port=4002 \
--target=500 \
--miner-address=$(cat keys2/poai_address.txt) \
--peer-multiaddr="/ip4/127.0.0.1/tcp/4001/p2p/<PEER_ID_FROM_NODE_1>"- Difficulty/Targets: Set via
--target(e.g., -1000000000000000000 for realistic mining; more negative values = harder). Retargets every 2016 blocks based on timestamps (seecore/difficulty.go). Blocks mine when LLM inference loss (hashed) <= target. Uses nonce-based probabilistic search like Bitcoin. - Subsidies/Rewards: Automatic on mined blocks (fixed amount, halving model). Rewards credit to miner's address; future transactions will enable sending/receiving.
- Procedural Quizzes: Mining auto-generates deterministic quizzes (e.g., math problems seeded by block height) for LLM inference—no external files needed.
- Verify: Watch logs for "Generated quiz: ...", "Block mined!", and chain sync. Nodes compete; successful mining earns subsidies.
- Troubleshooting: If LLM fails, check model path/threads. Data persists in
data1/data2for restarts. If commands fail, confirm you're in the repo root.
- Private Key: 64-character hex string (32 bytes) - KEEP SECRET
- Public Key: 128-character hex string (64 bytes) - derived from private key
- Address: 40-character hex string (20 bytes) - derived from public key, used for mining rewards
- Backup your private key - If lost, you cannot access mining rewards
- Use different addresses - Generate separate keys for different mining operations
- Secure storage - Store private keys offline or in encrypted storage
- Never share private keys - Only share your address for receiving rewards
# Check balance for your address
./poaid balance --addr=$(cat keys/poai_address.txt) --data-dir=data1
# Check balance on a different node
./poaid balance --addr=$(cat keys/poai_address.txt) --data-dir=data2Note: Balance checking works even when mining nodes are running. The command will show an error if the database is locked by another process.
If you lose your private key, you cannot recover access to mining rewards. Always:
- Keep multiple secure backups
- Use hardware wallets for large amounts (when supported)
- Test your backup recovery process
PoAI includes a complete transaction system for secure transfers between wallets.
# Send 1000 POAI to another address
./poaid send --to=RECIPIENT_ADDRESS_HERE \
--amount=1000 \
--privkey=YOUR_PRIVATE_KEY_HERE- Cryptographic Signatures: Only the private key holder can spend funds
- Transaction Hash: Unique identifier for each transaction
- Balance Verification: Network verifies sufficient funds before execution
- Double-Spend Protection: Prevents spending the same funds twice
- Immutable Ledger: Once confirmed, transactions cannot be reversed
- Create: Generate a transaction with recipient and amount
- Sign: Cryptographically sign with your private key
- Broadcast: Send to the network for inclusion in blocks
- Confirm: Transaction is included in a mined block
Note: Currently, transactions are created and signed but need to be manually added to the mempool for broadcasting. Full mempool integration is planned for future releases.
-
Epoch math
EpochBlocks(e.g. 2016 on main-net) defines each epoch's length.- Seed = block-hash of the previous epoch's last block.
-
EpochKey derivation
epochKey = Keccak256( seed ∥ epochIndex ) -
Procedural quiz generation
- Deterministic quiz generation based on block height and epoch key
- No external dataset files required
- Examples: math problems, logic puzzles, text completion tasks
-
Forward-pass & loss reduction
- Fixed, "eval"-mode AI model (e.g. TinyLlama-1.1B) runs inference on generated quizzes
- Compute scalar loss → hash-reduce to 256-bit integer ℓ̂
- Block is valid if
ℓ̂ < T(difficulty target)
- Miner runs a single-goroutine loop driven by
state.SubscribeHeads(), attempts quizzes on each tip, and broadcasts valid blocks via libp2p - Validator replays the same quiz pipeline in
validator/verify.goand rejects any block with mismatched ℓ̂ or header
- Block subsidy: 5 POAI per block (halving every 4 years)
- Transaction fees: gas charged in POAI for all EVM calls (planned)
- Inference-job fees: posters lock POAI in
InferenceMarket.sol; miners stake additional POAI and earn payments upon successful proof or get slashed on fraud (planned) - Stake-slash: invalid blocks lose GPU cost; mis-served jobs burn 90 % of worker stake, 10 % to challenger (planned)
- Security budget: subsidy + fees + job revenues align miner incentives to remain honest
| Component | Status |
|---|---|
| Quiz pipeline & procedural generation | ✅ Complete |
| Single-worker mining loop & orphan-pool import | ✅ Complete |
| Difficulty retarget (core/difficulty.go) | ✅ Complete |
| Persistent on-disk DB + pruning (core/storage) | ✅ Complete |
| libp2p gossip & peer discovery (net/p2p.go) | ⚪️ Stub |
| Wallet system & balance checking | ✅ Complete |
| Transaction creation & signing | ✅ Complete |
| Real LLM inference (llama.cpp) | ✅ Complete |
| Transaction broadcasting & mempool integration | ⚪️ Planned |
| InferenceMarket.sol + Go bindings | ⚪️ In progress |
| Metrics & Grafana exporter | ⚪️ Missing |
| Documentation & spec polish | ✅ Updated |
- go.mod not found: Ensure you're in the repo root directory (run
lsto seego.mod). Avoid running commands from parent or nested dirs. - Model download issues: Use the auth-required options above; Hugging Face enforces this for large files.
- Mining too slow: Increase
--target(easier difficulty) or use GPU layers. - Flag errors: Use
--peer-multiaddr(not--multiaddr) for connecting to peers. - Build errors on Linux: If you get "malformed import path" with
*.go, use explicit file listing:# Instead of: go build -tags llama -o poaid cmd/poaid/*.go # Use: go build -tags llama -o poaid cmd/poaid/main.go cmd/poaid/cli.go
- Invalid miner address: Ensure the address is a 40-character hex string (20 bytes). Use
./poaid generate-keyto create a valid address. - Address format error: The
--miner-addressflag expects hex format without the0xprefix. - Permission denied on key files: The private key file has restricted permissions (600). This is intentional for security.
- No mining rewards: Check that you're using the correct
--miner-addressand that blocks are being successfully mined.
PoAI provides a comprehensive CLI with multiple commands:
# Show all available commands
./poaid help
# Run as mining daemon
./poaid [flags]
# Generate new keypair
./poaid generate-key [flags]
# Check wallet balance
./poaid balance [flags]
# Send transaction
./poaid send [flags]
# Show help
./poaid help# Generate a new keypair
./poaid generate-key
# Generate and save keys to files
./poaid generate-key --save --output-dir=./keys
# Check balance for an address
./poaid balance --addr=YOUR_ADDRESS_HERE --data-dir=data1
# Send 1000 POAI to another address
./poaid send --to=RECIPIENT_ADDRESS_HERE \
--amount=1000 \
--privkey=YOUR_PRIVATE_KEY_HERE
# Start mining with your address
./poaid --miner-address=YOUR_ADDRESS --target=500 --model-path=models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf-
Daemon Flags:
--model-path,--target,--data-dir,--p2p-port,--peer-multiaddr,--miner-address -
Generate Key Flags:
--save,--output-dir -
Balance Flags:
--addr,--data-dir -
Send Flags:
--to,--amount,--privkey -
Open an issue with logs for other problems.
Open issues for bugs, logs, or suggestions. PRs welcome, especially for setup improvements or new features like transactions. Target v0.3.0 for economic layer.
- Apache 2.0 for all code.
PoAI unites provable AI work with blockchain security. Together we'll finish the last mile to a live test-net and beyond.
