codila125/foedus-blockchain

By codila125

β€’Updated 6 months ago

Foedus is a complete blockchain implementation featuring smart contracts with milestone tracking.

Image
Networking
API management
Web servers
0

1.1K

codila125/foedus-blockchain repository overview

⁠Foedus Blockchain

Immutable Contract Infrastructure

Features⁠ β€’ Quick Start⁠ β€’ API⁠ β€’ Contracts⁠ β€’ Deploy⁠

Version 0.4.0 Production Ready Go 1.25+ MIT License Docker Ready


⁠Overview

Foedus is a production-ready blockchain platform enabling governments and enterprises to create, manage, and enforce immutable contracts. Built for legislative compliance and corporate accountability, it provides tamper-proof records with full audit trails.

Built for:

  • πŸ›οΈ Government Bodies enforcing legislative contracts and public agreements
  • 🏒 Enterprises requiring legally binding, immutable contract records
  • βš–οΈ Regulatory Compliance with transparent, auditable contract histories
  • 🀝 Public-Private Partnerships coordinating multi-party agreements

⁠Features

β πŸ“œ Immutable Contract Records

Every contract, amendment, and approval is permanently recorded on the blockchain. Once committed, records cannot be altered or deletedβ€”ensuring absolute integrity for legal and regulatory purposes.

β πŸ›οΈ Multi-Party Governance

Support for multiple signatories including government agencies, corporate entities, and authorized representatives. All parties must cryptographically approve before contracts become active.

β πŸ“‹ Milestone-Based Execution

Track contract fulfillment through defined milestones. Each completion requires evidence submission and multi-party approval, creating a verifiable chain of accountability.

β πŸ” Cryptographic Security

Ed25519 digital signatures and SHA-256 hashing ensure non-repudiation. Every action is cryptographically signed, providing legally defensible proof of authorization.

β πŸ“Š Complete Audit Trail

Full transaction history accessible for regulatory audits, legal discovery, and compliance verification. Export complete blockchain records on demand.

β πŸš€ Enterprise Deployment

Production-ready Docker deployment with health monitoring, graceful shutdown, and persistent storage. Integrates with existing government and enterprise infrastructure via RESTful API.


⁠Quick Start

# Pull and run
docker pull codila125/foedus-blockchain:latest
docker run -d -p 3008:3008 --name foedus codila125/foedus-blockchain:latest

# Verify it's running
curl http://localhost:3008/health
# {"status":"ok"}
⁠With Persistent Storage
docker volume create foedus-data
docker volume create foedus-logs

docker run -d \
  --name foedus \
  -p 3008:3008 \
  -p 3009:3009 \
  -p 3010:3010 \
  -v foedus-data:/app/data \
  -v foedus-logs:/var/log/foedus \
  codila125/foedus-blockchain:0.4.0
⁠Build from Source
git clone https://github.com/codila125/foedus-blockchain.git
cd foedus-blockchain
docker build -t foedus-blockchain .
docker run -d -p 3008:3008 --name foedus foedus-blockchain

⁠API Reference

Base URL: http://localhost:3008

⁠Health Check
GET /health

Returns {"status":"ok"} when service is operational.

⁠Wallet Operations
EndpointMethodDescription
/blockchain/createwalletGETGenerate new wallet
/blockchain/listaddressesGETList all wallet addresses
/blockchain/getbalance/{address}GETGet wallet balance
⁠Smart Contract Operations
EndpointMethodDescription
/blockchain/createcontract/{address}POSTCreate new contract
/blockchain/getcontract/{contractID}GETGet contract details
/blockchain/approvecontractPOSTApprove contract
/blockchain/approvemilestonePOSTComplete milestone
/blockchain/cancelcontractPOSTCancel contract
⁠Blockchain Queries
EndpointMethodDescription
/blockchain/printchainGETExport full blockchain

⁠Smart Contracts

⁠Create a Contract
curl -X POST http://localhost:3008/blockchain/createcontract/{creator_address} \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Infrastructure Development Agreement",
    "description": "Public-private partnership for highway construction",
    "milestones": [
      {
        "title": "Phase 1: Land Acquisition",
        "description": "Complete land acquisition and permits",
        "value": 5000000,
        "due_date": 1762329600
      },
      {
        "title": "Phase 2: Construction",
        "description": "Complete primary construction",
        "value": 25000000,
        "due_date": 1793865600
      }
    ],
    "parties": [
      {"address": "{government_agency}", "role": "REGULATOR"},
      {"address": "{contractor}", "role": "CONTRACTOR"},
      {"address": "{oversight_body}", "role": "ARBITRATOR"}
    ],
    "terms": "Funds released upon milestone approval by all parties"
  }'
⁠Contract Lifecycle
DRAFT β†’ ACTIVE β†’ COMPLETED
   ↓       ↓
   └───────┴──→ CANCELLED
  1. DRAFT: Contract proposed, awaiting party approvals
  2. ACTIVE: All authorized signatories approved, milestones in progress
  3. COMPLETED: All milestones fulfilled and verified
  4. CANCELLED: Contract terminated with full audit record
⁠Use Cases
SectorApplication
GovernmentLegislative contracts, procurement agreements, inter-agency MOUs
InfrastructurePublic-private partnerships, construction milestones
HealthcarePharmaceutical supply contracts, compliance agreements
FinanceRegulatory filings, audit trails, cross-border agreements
EnergyPower purchase agreements, environmental compliance

⁠Deployment

⁠Environment Variables
VariableDefaultDescription
NODE_ID3008API server port
SOURCE_NODE_ID3008Source node identifier
MINER_NODE_ID3011Miner node identifier
⁠Ports
PortService
3008HTTP API
3009P2P Source Node
3010P2P Miner Node
⁠Health Checks

Docker health checks are built-in:

# Check container health
docker inspect --format='{{.State.Health.Status}}' foedus
⁠Logs
# View logs
docker logs -f foedus

# Access log files (if using volumes)
docker exec foedus cat /var/log/foedus/source.log

⁠Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      HTTP API (Chi)                     β”‚
β”‚              GET/POST /blockchain/*                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Blockchain Core                       β”‚
β”‚     UTXO Model β€’ Proof-of-Work β€’ Smart Contracts        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Infrastructure                        β”‚
β”‚       libp2p Network β€’ PebbleDB β€’ Ed25519 Crypto        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⁠Technical Specifications

ComponentTechnology
ConsensusProof-of-Work (SHA-256)
SignaturesEd25519
StoragePebbleDB (LSM-tree)
Networkinglibp2p (TCP)
SerializationProtocol Buffers v3
API FrameworkChi Router

⁠Module Documentation

ModuleDescription
api/⁠RESTful HTTP server
blockchain/⁠Core consensus engine
network/⁠P2P communication
wallet/⁠Key management
database/⁠Storage layer
merkle/⁠Transaction verification
cli/⁠Command-line interface

⁠Testing

Foedus maintains a comprehensive test suite to ensure reliability, correctness, and performance. All tests are run using Go's native testing framework.

⁠Test Suite Summary
MetricValue
Total Unit Tests805
Pass Rate100%
Test Duration~30 seconds
Race Condition DetectionPassed
⁠Running Tests
# Run all tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Run tests with race detector
go test -race ./...

# Run benchmarks
go test -bench=. -benchmem ./...
⁠Test Coverage
PackageCoverageStatus
merkle100.0%βœ… Excellent
wallet88.6%βœ… Excellent
database86.1%βœ… Excellent
blockchain27.7%πŸ”Ά Partial
cli25.1%πŸ”Ά Partial
api/server18.8%πŸ”Ά Partial
api13.3%πŸ”Ά Partial
network11.0%πŸ”Ά Partial
api/handler0.7%πŸ”Ά Partial
Overall20.2%πŸ”Ά Acceptable

Note: Coverage gaps primarily exist in integration-level components (network sync, API handlers) that require live multi-node environments. Core cryptographic and data integrity components (Merkle, wallet, database) have excellent coverage.

⁠Performance Benchmarks
⁠Wallet Operations
OperationTime/OpOps/SecMemory
Key Pair Generation14.89 ΞΌs80,172128 B
Address Validation543 ns2,195,322288 B
Base58 Encode985 ns1,217,79496 B
Public Key Hash48.68 ns24,537,0120 B
⁠Database Operations
OperationTime/OpOps/SecMemory
Batch Write265 ns4,057,1303 B
PebbleDB Write2.54 ms7691,466 B
PebbleDB Read192 ns5,476,0520 B
⁠Merkle Tree Operations
Tree SizeTime/OpOps/SecMemory
Leaf Node77.51 ns15,409,84480 B
Small (10 leaves)805 ns1,490,9061,224 B
Medium (100 leaves)13.8 ΞΌs86,64225 KB
Large (1000 leaves)214 ΞΌs5,559415 KB
⁠Network Operations
OperationTime/OpOps/SecMemory
Block Serialization134 ns8,265,553240 B
Block Deserialization167 ns7,133,660352 B
Contract Serialization377 ns3,182,455408 B
Large Block (1MB)143 ΞΌs7,6002.1 MB
⁠API Load Testing

Load tests were conducted with 10 concurrent clients over 5 seconds:

EndpointThroughputAvg LatencyP95 LatencyError Rate
/health3,880 req/s2.57 ms8.87 ms0.00%
/createwallet958 req/s10.43 ms12.41 ms0.00%
/listaddresses781 req/s12.81 ms12.66 ms0.00%
/printchain678 req/s14.75 ms10.09 ms0.00%
⁠Contract Confirmation Metrics
MetricValue
Minimum Confirmation3.64 ms
Average Confirmation5.15 ms
Maximum Confirmation8.41 ms
P95 Confirmation5.07 ms
Success Rate100%
⁠Security Testing
  • Race Condition Detection: All tests pass with -race flag enabled
  • Cryptographic Validation: Ed25519 signatures and SHA-256 hashing verified
  • Serialization Integrity: JSON/Protobuf round-trip tests pass
  • Address Format Validation: Base58Check encoding verified
⁠CI/CD

Automated tests run on every push via GitHub Actions:

# .github/workflows/test.yml
- name: Run tests with race detector
  run: go test -race -v ./...
- name: Run benchmarks
  run: go test -bench=. -benchmem -run=^$ ./...

⁠Why Foedus?

⁠Speed: Orders of Magnitude Faster
BlockchainConfirmation TimeRelative Speed
Foedus~5 ms1x (baseline)
Bitcoin~10 minutes120,000x slower
Ethereum~12-15 seconds2,400x slower

Foedus achieves sub-millisecond contract confirmation, making it suitable for real-time applications.

⁠Purpose-Built for Contracts

Unlike general-purpose blockchains, Foedus is designed specifically for contract management:

FeatureFoedusBitcoinEthereumHyperledger
Native contract lifecycleβœ…βŒβŒβŒ
Milestone trackingβœ…βŒβŒβŒ
Multi-party approvalβœ…βŒβŒβœ…
ICCT indexβœ…βŒβŒβŒ
Hybrid storageβœ…βŒβŒβŒ
⁠Built-in Milestone Workflow

Ethereum requires writing custom Solidity smart contracts for milestone-based agreements. Foedus provides this functionality out of the box:

DRAFT β†’ ACTIVE β†’ COMPLETED
   ↓       ↓
   └───────┴──→ CANCELLED
⁠ICCT: Incomplete Contract Tracking

Foedus includes a specialized index for fast lookup of active contractsβ€”no full chain scan required.

⁠Hybrid Storage Architecture
Data TypeStorageBenefit
Contract events, approvals, milestonesFoedus (immutable)Verifiable audit trail
User profiles, messages, jobsMongoDB (fast)Responsive UX
Evidence files, attachmentsObject storageCost-effective
⁠Predefined Contract Structure

vs Ethereum's Solidity:

  • More secure: No arbitrary code execution
  • Simpler: No gas optimization needed
  • Predictable: No smart contract vulnerabilities
⁠Lightweight Deployment

Runs on minimal hardwareβ€”no mining farms required. Perfect for private/consortium networks.


⁠Support


⁠License

MIT License - see LICENSE⁠ for details.


Foedus v0.4.0 β€” Immutable Contract Infrastructure for Government & Enterprise

Tag summary

Content type

Image

Digest

sha256:2e0891dbf…

Size

777 Bytes

Last updated

6 months ago

docker pull codila125/foedus-blockchain:sha256-4c673b770eb92173107b8070fd9a9f173b5b2490909dc2aa570b8474c8c43946.sig