Skip to content

arkhai-io/git-commit-trading

Repository files navigation

Git Escrows CLI

A sophisticated git-based escrow system for code challenges, bounties, and trustless development workflows. This system bridges Git commits with blockchain verification, enabling secure code-for-payment exchanges with cryptographic commit verification.

Core Features

  • Cryptographic Commit Verification: Verify Git commits using SSH, PGP, or X.509 signatures
  • Blockchain Integration: Smart contract-based escrow system on Ethereum
  • Multi-Key Support: Register and verify SSH Ed25519/ECDSA, PGP v4, and X.509 keys
  • Cross-Platform Builds: Binary distribution for Linux, macOS, and Windows
  • Oracle Integration: Automated test execution and verification
  • Comprehensive CLI: Full-featured command-line interface for all operations

Prerequisites

  • Bun >= 1.2.20
  • Node.js >= 18.x (for contract compilation)
  • Forge (Foundry) for smart contract builds
  • Git with configured SSH/PGP keys

Quick Start

Installation

# Install dependencies
bun install

# Build smart contracts
bun run build:contracts

# Build CLI binary
bun run build:binary

Configuration

Create a .env file or use the CLI to generate one:

# Initialize client with private key and network
./bin/git-escrows new-client --privateKey 0x... --network anvil

Register Your Git Keys

# Register SSH key
./bin/git-escrows register-key --path ~/.ssh/id_ed25519.pub

# Register PGP key
./bin/git-escrows register-key --pgp-key-file ~/.gnupg/pubkey.asc

# Register X.509 certificate
./bin/git-escrows register-key --x509-cert-file ./cert.pem

# Verify registration
./bin/git-escrows check-key --verbose

CLI Commands

Core Operations

Submit Escrow Demand

./bin/git-escrows submit \
  --tests-repo https://github.com/user/tests.git \
  --tests-commit abc123... \
  --reward 1000000000000000000 \
  --tests-command "bun test" \
  --arbiter 0x... \
  --token 0x...

List Available Escrows

# List all escrows
./bin/git-escrows list

# Filter by status
./bin/git-escrows list --status open

# Filter by address (buyer or recipient)
./bin/git-escrows list --address 0x...

# Show detailed information
./bin/git-escrows list --verbose

# Export as JSON or CSV
./bin/git-escrows list --format json
./bin/git-escrows list --format csv

# Combine options
./bin/git-escrows list --status open --address 0x... --verbose --limit 10

Note: Requires ERC20_ESCROW_OBLIGATION_ADDRESS in your .env file. The command queries the blockchain directly using event logs from the ERC20EscrowObligation contract.

Output includes:

  • Escrow UID, status, amount, and token address
  • Buyer and arbiter addresses
  • Test repository URL (GitHub repo)
  • Test commit hash
  • Creation timestamp and expiration time

Fulfill Escrow (Submit Solution)

./bin/git-escrows fulfill \
  --escrow-id 1 \
  --solution-repo https://github.com/dev/solution.git \
  --solution-commit def456...

Collect Rewards

./bin/git-escrows collect --escrow-id 1

Key Management

Register Keys

# SSH Keys
./bin/git-escrows register-key \
  --public-key-file ~/.ssh/id_ed25519.pub \
  --private-key-file ~/.ssh/id_ed25519

# PGP Keys  
./bin/git-escrows register-key \
  --pgp-key-file ~/.gnupg/pubkey.asc

# X.509 Certificates
./bin/git-escrows register-key \
  --x509-cert-file ./certificate.pem

Verify Registration

./bin/git-escrows check-key --address 0x... --verbose

Development Server

Start the verification oracle server:

./bin/git-escrows server --port 3000 --config config.json

Usage Scenarios

Scenario 1: Submit a Demand (Challenge Creator)

Use Case: You want to create a coding challenge or bounty with specific test requirements and offer a reward for a working solution.

Prerequisites

  • Test repository with comprehensive test suite
  • Ethereum wallet with sufficient tokens for reward
  • Git keys registered on-chain

Step-by-Step Process

1. Prepare Your Test Repository

# Ensure your test repo has:
# - Clear test cases
# - Build/install instructions
# - Specific commit with frozen requirements

git clone https://github.com/yourorg/challenge-tests.git
cd challenge-tests
git log --oneline -n 5  # Note the commit hash you want to use

2. Setup Your Environment

# Initialize client configuration
./bin/git-escrows new-client \
  --privateKey 0x1234567890abcdef... \
  --network sepolia

# Register your Git signing key (if not done already)
./bin/git-escrows register-key --path ~/.ssh/id_ed25519.pub

3. Submit the Escrow Demand

./bin/git-escrows submit \
  --tests-repo https://github.com/yourorg/challenge-tests.git \
  --tests-commit a1b2c3d4e5f6... \
  --reward 1000000000000000000 \
  --tests-command "bun test" \
  --arbiter 0xArbiterAddress... \
  --token 0xTokenContractAddress...

4. Monitor Your Escrow

# List your created escrows
./bin/git-escrows list --address 0xYourAddress

# Check status periodically
watch -n 30 './bin/git-escrows list --address 0xYourAddress'

Scenario 2: Submit a Solution (Developer)

Use Case: You found an interesting coding challenge and want to submit your solution to claim the reward.

Prerequisites

  • Solution implemented and tested locally
  • Git commits signed with registered key
  • Ethereum wallet for transactions

Step-by-Step Process

1. Find Available Challenges

# List all available escrows
./bin/git-escrows list

# Or filter by specific criteria
./bin/git-escrows list --address 0xSpecificDemander

2. Analyze the Challenge

# Clone the test repository to understand requirements
git clone https://github.com/challenger/test-repo.git
cd test-repo
git checkout a1b2c3d4e5f6...  # Use the specific commit from escrow

# Read requirements and test cases
cat README.md
ls tests/

3. Develop Your Solution

# Create your solution repository
git clone https://github.com/yourusername/solution-repo.git
cd solution-repo

# Implement your solution
# ... code, test, iterate ...

# Ensure tests pass locally against the challenge tests
git add .
git commit -S -m "Complete solution for challenge #123"
git push origin main

# Note your final commit hash
git log --oneline -n 1

4. Setup Environment and Register Keys

# Setup your client (if not done already)
./bin/git-escrows new-client \
  --privateKey 0xYourPrivateKey... \
  --network sepolia

# Register your signing key (required for commit verification)
./bin/git-escrows register-key \
  --public-key-file ~/.ssh/id_ed25519.pub \
  --private-key-file ~/.ssh/id_ed25519

5. Submit Your Solution

./bin/git-escrows fulfill \
  --escrow-id 42 \
  --solution-repo https://github.com/yourusername/solution-repo.git \
  --solution-commit def456abc789...

6. Wait for Verification and Collect Reward

# Monitor verification status
./bin/git-escrows list --address 0xYourAddress

# Once verified and approved, collect your reward
./bin/git-escrows collect --escrow-id 42

Scenario 3: Run Your Own Oracle Server

Use Case: You want to run a verification oracle server to automatically test and verify solution submissions for escrow contracts.

Prerequisites

  • Reliable server infrastructure
  • Access to blockchain network
  • Proper security configuration

Step-by-Step Process

1. Server Setup and Configuration

# Clone and setup the project
git clone https://github.com/yourorg/git-escrows.git
cd git-escrows/git-app
bun install
bun run build:contracts
bun run build:binary

2. Configure Oracle Environment

# Create oracle-specific .env
./bin/git-escrows new-client \
  --privateKey 0xOraclePrivateKey... \
  --network sepolia

# Register oracle's verification keys
./bin/git-escrows register-key --path ~/.ssh/id_rsa.pub

3. Create Oracle Configuration File

# Create config/oracle-config.json
{
  "repositories": {
    "source": {
      "url": "dynamic",  # Will be provided by escrow submissions
      "branch": "main",
      "buildCommand": "bun install",
      "testCommand": "bun test",
      "installCommand": "bun install"
    },
    "testcase": {
      "url": "dynamic",  # Will be provided by escrow demands
      "branch": "main",
      "buildCommand": "bun install", 
      "testCommand": "bun test",
      "installCommand": "bun install"
    }
  },
  "execution": {
    "timeout": 300000,           # 5 minutes max per test
    "cleanupAfterExecution": true,
    "isolatedEnvironment": true,
    "tempDirectory": "/tmp/git-escrows",
    "maxMemoryMB": 1024,
    "allowedCommands": ["bun", "npm", "yarn", "pnpm", "cargo", "go", "python", "node"]
  },
  "security": {
    "enableNetworkAccess": false,    # Block network during tests
    "restrictFileSystem": true,      # Sandbox file access
    "timeboxExecution": true,        # Enforce strict timeouts
    "logAllActivity": true           # Audit trail
  },
  "oracle": {
    "autoVerifyEscrows": true,       # Automatically process new escrows
    "maxConcurrentJobs": 3,          # Parallel execution limit
    "retryFailedTests": 2,           # Retry attempts for flaky tests
    "enableDetailedLogging": true
  }
}

4. Start Oracle Server

# Start in production mode
./bin/git-escrows server \
  --port 3000 \
  --config config/oracle-config.json \
  --log-level info

# Or with PM2 for production deployment
pm2 start ./bin/git-escrows --name "git-escrows-oracle" -- \
  server --port 3000 --config config/oracle-config.json

5. Monitor Oracle Operations

# Check oracle status and logs
./bin/git-escrows server --status
tail -f logs/oracle.log

# Monitor processed escrows
./bin/git-escrows list --oracle-stats

# Health check endpoint
curl http://localhost:3000/health

6. Production Deployment Considerations

# Setup reverse proxy (nginx)
# Configure SSL/TLS certificates
# Setup monitoring and alerting
# Configure log rotation
# Setup automatic backups of verification results

# Example systemd service
sudo cp scripts/git-escrows-oracle.service /etc/systemd/system/
sudo systemctl enable git-escrows-oracle
sudo systemctl start git-escrows-oracle

Repository Structure Requirements

Test Repository Structure (Challenge/Demand)

The test repository should contain comprehensive test cases that define the challenge requirements. This repository will be cloned and executed by the oracle to verify solutions.

Required Structure

test-repo/
β”œβ”€β”€ README.md                 # Challenge description and requirements
β”œβ”€β”€ package.json             # Dependencies and scripts (for Node.js/Bun)
β”œβ”€β”€ bun.lockb               # Lock file for reproducible builds
β”œβ”€β”€ tests/                  # Test directory
β”‚   β”œβ”€β”€ unit/              # Unit tests
β”‚   β”œβ”€β”€ integration/       # Integration tests
β”‚   └── acceptance/        # Acceptance criteria tests
β”œβ”€β”€ fixtures/              # Test data and fixtures
β”‚   β”œβ”€β”€ input/            # Sample input data
β”‚   └── expected/         # Expected output data
β”œβ”€β”€ docs/                 # Additional documentation
β”‚   β”œβ”€β”€ API.md           # API specification (if applicable)
β”‚   └── examples.md      # Usage examples
└── .gitignore           # Git ignore rules

Example Test Repository (JavaScript/TypeScript)

// package.json
{
  "name": "fibonacci-challenge-tests",
  "version": "1.0.0",
  "description": "Test suite for Fibonacci sequence challenge",
  "scripts": {
    "test": "bun test",
    "test:unit": "bun test tests/unit",
    "test:integration": "bun test tests/integration"
  },
  "devDependencies": {
    "@types/bun": "latest",
    "bun": "^1.2.0"
  }
}
// tests/unit/fibonacci.test.ts
import { test, expect } from 'bun:test';

test('fibonacci sequence basic cases', () => {
  // Tests will import from the solution repo
  const { fibonacci } = require('../../../solution/src/fibonacci');
  
  expect(fibonacci(0)).toBe(0);
  expect(fibonacci(1)).toBe(1);
  expect(fibonacci(2)).toBe(1);
  expect(fibonacci(10)).toBe(55);
});

test('fibonacci performance test', () => {
  const { fibonacci } = require('../../../solution/src/fibonacci');
  
  const start = performance.now();
  const result = fibonacci(40);
  const duration = performance.now() - start;
  
  expect(result).toBe(102334155);
  expect(duration).toBeLessThan(1000); // Must complete within 1 second
});

Example Test Repository (Rust)

# Cargo.toml
[package]
name = "sorting-challenge-tests"
version = "0.1.0"
edition = "2021"

[dependencies]
# Add solution crate as dependency
solution = { path = "../solution" }

[dev-dependencies]
criterion = "0.5"
// tests/integration_test.rs
use solution::sort_algorithm;

#[test]
fn test_empty_array() {
    let mut arr: Vec<i32> = vec![];
    sort_algorithm(&mut arr);
    assert_eq!(arr, vec![]);
}

#[test]
fn test_performance_large_array() {
    let mut arr: Vec<i32> = (0..100000).rev().collect();
    let start = std::time::Instant::now();
    sort_algorithm(&mut arr);
    let duration = start.elapsed();
    
    assert!(arr.windows(2).all(|w| w[0] <= w[1])); // Verify sorted
    assert!(duration.as_millis() < 5000); // Must complete within 5 seconds
}

Solution Repository Structure (Fulfillment)

The solution repository contains the implementation that attempts to satisfy the test requirements.

Required Structure

solution-repo/
β”œβ”€β”€ README.md               # Solution description and approach
β”œβ”€β”€ package.json           # Dependencies and build scripts
β”œβ”€β”€ bun.lockb              # Lock file
β”œβ”€β”€ src/                   # Source code
β”‚   β”œβ”€β”€ main.ts           # Main entry point
β”‚   β”œβ”€β”€ lib/              # Library modules
β”‚   └── utils/            # Utility functions
β”œβ”€β”€ docs/                 # Documentation
β”‚   β”œβ”€β”€ approach.md       # Technical approach
β”‚   └── complexity.md     # Time/space complexity analysis
β”œβ”€β”€ examples/             # Usage examples
└── .gitignore           # Git ignore rules

Example Solution Repository (JavaScript/TypeScript)

// package.json
{
  "name": "fibonacci-solution",
  "version": "1.0.0",
  "description": "Optimized Fibonacci sequence implementation", 
  "main": "src/fibonacci.ts",
  "scripts": {
    "build": "bun build src/fibonacci.ts --outdir dist",
    "test": "bun test",
    "start": "bun run src/main.ts"
  },
  "exports": {
    ".": "./src/fibonacci.ts"
  }
}
// src/fibonacci.ts
const memo = new Map<number, number>();

export function fibonacci(n: number): number {
  if (n <= 1) return n;
  
  if (memo.has(n)) {
    return memo.get(n)!;
  }
  
  const result = fibonacci(n - 1) + fibonacci(n - 2);
  memo.set(n, result);
  return result;
}

// src/main.ts
import { fibonacci } from './fibonacci';

console.log('Fibonacci(10):', fibonacci(10));

Example Solution Repository (Rust)

# Cargo.toml
[package]
name = "solution"
version = "0.1.0"
edition = "2021"

[lib]
name = "solution"
path = "src/lib.rs"

[[bin]]
name = "main"
path = "src/main.rs"
// src/lib.rs
pub fn sort_algorithm(arr: &mut [i32]) {
    // Optimized quicksort implementation
    if arr.len() <= 1 {
        return;
    }
    quicksort(arr, 0, arr.len() - 1);
}

fn quicksort(arr: &mut [i32], low: usize, high: usize) {
    if low < high {
        let pi = partition(arr, low, high);
        if pi > 0 {
            quicksort(arr, low, pi - 1);
        }
        quicksort(arr, pi + 1, high);
    }
}

Repository Integration Requirements

  1. Test Discovery: Tests must be able to import/link with solution code
  2. Build Dependencies: Solution must build successfully before tests run
  3. Output Format: Tests should produce clear pass/fail results
  4. Performance Benchmarks: Include performance requirements in tests
  5. Edge Cases: Comprehensive test coverage including edge cases

Command Output Examples

List Command Output

./bin/git-escrows list

Example Output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                               AVAILABLE ESCROWS                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ID: 1                                                                           β”‚
β”‚ Status: PENDING_FULFILLMENT                                                  β”‚
β”‚ Demander: 0xa1b2c3d4e5f6...                                                    β”‚
β”‚ Reward: 1.5 ETH                                                                β”‚
β”‚ Token: ETH (Native)                                                             β”‚
β”‚ Tests: https://github.com/challenges/fibonacci-optimization                     β”‚
β”‚ Commit: a1b2c3d4e5f6789...                                                      β”‚
β”‚ Test Command: bun test                                                          β”‚
β”‚ Arbiter: 0x1234567890ab...                                                     β”‚
β”‚ Created: 2025-09-28 14:30:25 UTC                                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ID: 2                                                                           β”‚
β”‚ Status: UNDER_REVIEW                                                         β”‚
β”‚ Demander: 0xf1e2d3c4b5a6...                                                    β”‚
β”‚ Reward: 500 USDC                                                               β”‚
β”‚ Token: 0xa0b86991c431...                                                       β”‚
β”‚ Tests: https://github.com/challenges/sorting-algorithms                         β”‚
β”‚ Commit: f1e2d3c4b5a6...                                                        β”‚
β”‚ Test Command: cargo test                                                        β”‚
β”‚ Arbiter: 0xabcdef123456...                                                     β”‚
β”‚ Fulfillment: 0x9876543210fe... (pending verification)                          β”‚
β”‚ Created: 2025-09-29 09:15:42 UTC                                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ID: 3                                                                           β”‚
β”‚ Status: COMPLETED                                                            β”‚
β”‚ Demander: 0x1111222233334444...                                                β”‚
β”‚ Fulfiller: 0x5555666677778888...                                               β”‚
β”‚ Reward: 0.8 ETH                                                                β”‚
β”‚ Token: ETH (Native)                                                             β”‚
β”‚ Tests: https://github.com/challenges/web3-integration                           β”‚
β”‚ Solution: https://github.com/solutions/web3-solution                            β”‚
β”‚ Completed: 2025-09-27 18:45:12 UTC                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Summary: 3 total escrows (1 available, 1 under review, 1 completed)
Total Value Locked: 2.3 ETH + 500 USDC

Check Key Command Output

./bin/git-escrows check-key --verbose

Example Output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          GIT KEY REGISTRATION STATUS                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Ethereum Address: 0xa1b2c3d4e5f6789abcdef1234567890abcdef12                     β”‚
β”‚ Network: Sepolia Testnet                                                        β”‚
β”‚ Registry Contract: 0x1234567890abcdef...                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ SSH Ed25519 Key                                                              β”‚
β”‚ Status: REGISTERED                                                            β”‚
β”‚ Public Key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGq...                         β”‚
β”‚ Fingerprint: SHA256:k4h9l2j3n4m5o6p7q8r9s0t1u2v3w4x5y6z7                       β”‚
β”‚ Registration TX: 0xabcdef1234567890...                                          β”‚
β”‚ Block: 4,521,337 (2025-09-28 14:25:31 UTC)                                     β”‚
β”‚ Git Config: user.signingkey matches registered key                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ PGP Key                                                                      β”‚
β”‚ Status: NOT REGISTERED                                                        β”‚
β”‚ Local Key: Found (4096-bit RSA, expires 2026-09-28)                            β”‚
β”‚ Suggestion: Run `./bin/git-escrows register-key --pgp-key-file ~/.gnupg/...`   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ X.509 Certificate                                                            β”‚
β”‚ Status: NOT REGISTERED                                                        β”‚
β”‚ Local Cert: Not found                                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Verification Capability: SSH signatures (YES), PGP signatures (NO), X.509 signatures (NO)
Ready to submit solutions with SSH-signed commits

Submit Command Output

./bin/git-escrows submit --tests-repo https://github.com/challenges/fibonacci --tests-commit a1b2c3d4 --reward 1500000000000000000

Example Output:

Creating new escrow demand...

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                             ESCROW SUBMISSION                                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Tests Repository: https://github.com/challenges/fibonacci                       β”‚
β”‚ Tests Commit: a1b2c3d4e5f6789abcdef1234567890abcdef12                          β”‚
β”‚ Reward Amount: 1.5 ETH                                                         β”‚
β”‚ Token: ETH (Native)                                                             β”‚
β”‚ Test Command: bun test                                                          β”‚
β”‚ Commit Algorithm: SHA256                                                        β”‚
β”‚ Arbiter: 0x1234567890abcdef... (default)                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Validating repository access...                                              β”‚
β”‚ Repository accessible                                                         β”‚
β”‚ Commit exists and is signed                                                   β”‚
β”‚ Test command executable                                                       β”‚
β”‚ Sufficient balance for reward + gas                                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Broadcasting transaction...                                                  β”‚
β”‚ Transaction Hash: 0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef12     β”‚
β”‚ Gas Used: 342,156                                                              β”‚
β”‚ Gas Price: 20 gwei                                                             β”‚
β”‚ Total Cost: 0.006843 ETH                                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Waiting for confirmation...                                                   β”‚
β”‚ Transaction confirmed in block 4,521,445                                     β”‚
β”‚ Escrow created successfully!                                                 β”‚
β”‚                                                                                 β”‚
β”‚ Escrow ID: 42                                                               β”‚
β”‚ Explorer: https://sepolia.etherscan.io/tx/0xabcdef...                       β”‚
β”‚ Monitor: ./bin/git-escrows list --address 0xa1b2c3d4e5f6...                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Fulfill Command Output

./bin/git-escrows fulfill --escrow-id 42 --solution-repo https://github.com/dev/fibonacci-solution --solution-commit def456

Example Output:

Submitting solution for escrow #42...

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                            SOLUTION SUBMISSION                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Escrow ID: 42                                                                   β”‚
β”‚ Solution Repository: https://github.com/dev/fibonacci-solution                  β”‚
β”‚ Solution Commit: def456abc789def456abc789def456abc789def456                     β”‚
β”‚ Submitter: 0x9876543210fedcba...                                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Pre-submission validation...                                                 β”‚
β”‚ Escrow exists and is accepting solutions                                     β”‚
β”‚ Solution repository accessible                                               β”‚
β”‚ Commit exists and is properly signed                                         β”‚
β”‚ Commit signature matches registered key                                      β”‚
β”‚ No previous submission from this address                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Submitting to blockchain...                                                  β”‚
β”‚ Transaction Hash: 0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba09     β”‚
β”‚ Gas Used: 198,234                                                              β”‚
β”‚ Total Cost: 0.003965 ETH                                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Waiting for oracle verification...                                           β”‚
β”‚ Oracle processing started                                                    β”‚
β”‚ Cloning repositories...                                                      β”‚
β”‚ Building solution...                                                        β”‚
β”‚ Running tests...                                                             β”‚
β”‚ All tests passed! (32/32)                                                    β”‚
β”‚ Performance benchmarks met                                                   β”‚
β”‚ Solution verified successfully!                                              β”‚
β”‚                                                                                 β”‚
β”‚ Reward pending arbiter approval                                              β”‚
β”‚ Monitor: ./bin/git-escrows list --address 0x9876543210fe...                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Server Status Output

./bin/git-escrows server --status

Example Output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                            ORACLE SERVER STATUS                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Status: RUNNING                                                              β”‚
β”‚ Uptime: 2d 14h 32m 18s                                                         β”‚
β”‚ Port: 3000                                                                      β”‚
β”‚ Config: config/oracle-config.json                                              β”‚
β”‚ Process ID: 15432                                                               β”‚
β”‚ Memory Usage: 248 MB / 1024 MB                                                 β”‚
β”‚ CPU Usage: 12.3%                                                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ VERIFICATION STATISTICS                                                         β”‚
β”‚ Total Verifications: 127                                                       β”‚
β”‚ Successful: 89 (70.1%)                                                         β”‚
β”‚ Failed: 31 (24.4%)                                                             β”‚
β”‚ Error/Timeout: 7 (5.5%)                                                        β”‚
β”‚ Average Processing Time: 43.2 seconds                                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ CURRENT QUEUE                                                                   β”‚
β”‚ Active Jobs: 2/3                                                               β”‚
β”‚ Pending: 1                                                                     β”‚
β”‚                                                                                 β”‚
β”‚ Job #1: Escrow 45 - fibonacci-challenge (2m 15s)                              β”‚
β”‚ Job #2: Escrow 47 - sorting-algorithms (45s)                                  β”‚
β”‚ Job #3: Escrow 48 - web3-integration (queued)                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ NETWORK STATUS                                                                  β”‚
β”‚ Blockchain: Sepolia Testnet                                                    β”‚
β”‚ RPC Status: Connected                                                        β”‚
β”‚ Block Height: 4,521,789                                                        β”‚
β”‚ Gas Price: 15.2 gwei                                                           β”‚
β”‚ Oracle Address: 0x1111222233334444...                                          β”‚
β”‚ Balance: 0.245 ETH                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Health Check: All systems operational
Performance: Normal (avg response time: 120ms)

Project Structure

src/
β”œβ”€β”€ cli/                    # CLI interface and commands
β”‚   β”œβ”€β”€ git-escrows.ts     # Main CLI entry point
β”‚   └── commands/          # Individual command implementations
β”œβ”€β”€ clients/               # Blockchain client abstractions
β”‚   β”œβ”€β”€ commitObligation.ts
β”‚   └── gitIdentityRegistry.ts
β”œβ”€β”€ contracts/             # Smart contract ABIs and types
β”œβ”€β”€ services/              # Core business logic
β”‚   └── verificationService.ts
β”œβ”€β”€ utils/                 # Utility functions
β”‚   β”œβ”€β”€ gitVerification.ts
β”‚   β”œβ”€β”€ keyUtils.ts
β”‚   └── cryptoUtils.ts
└── test-execution/        # Test execution engine

contract/                  # Smart contracts (Solidity)
tests/                    # Comprehensive test suites
bin/                      # Compiled binaries

Testing

Run Test Suite

# Build binary first (required for CLI tests)
bun run build:binary

# Run all tests
bun test

# Run specific test categories
bun test ./tests/integration-test.test.ts
bun test ./tests/gitKeyRegistration.test.ts
bun test ./tests/commitObligation.test.ts

Test Categories

  • Unit Tests: Individual component testing
  • Integration Tests: End-to-end workflow validation
  • Security Tests: Cryptographic verification testing
  • Multi-language Tests: Cross-platform execution testing

Build & Distribution

Local Development

bun run dev          # Watch mode
bun run start        # Standard execution
bun run cli          # Direct CLI access

Production Builds

bun run build:binary           # Current platform
bun run build:binary:linux     # Linux x64
bun run build:binary:windows   # Windows x64
bun run build:all              # All platforms

Package Distribution

bun run build                  # ESM/CJS library builds

Configuration

Environment Variables (.env)

The .env file contains blockchain connection and authentication credentials. This is your personal configuration for interacting with Ethereum networks and smart contracts.

Purpose:

  • Authenticate CLI commands with your private key
  • Connect to specific blockchain networks (local/testnet/mainnet)
  • Define smart contract addresses for your deployment

Create .env file with:

# Your Ethereum private key (required for all transactions)
PRIVATE_KEY=0x1234567890abcdef...

# Blockchain RPC endpoint 
RPC_URL=http://localhost:8545                    # Local development (Anvil)
# RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY  # Sepolia testnet
# RPC_URL=https://mainnet.infura.io/v3/YOUR_KEY  # Ethereum mainnet

# Smart contract deployment addresses (network-specific)
GIT_IDENTITY_REGISTRY_ADDRESS=0xabcd...         # Git key registry contract
COMMIT_OBLIGATION_ADDRESS=0xefgh...             # Escrow contract
ORACLE_ADDRESS=0xijkl...                        # Verification oracle contract

# Optional: Gas configuration
GAS_LIMIT=500000
GAS_PRICE=20000000000

Security Note: Never commit .env files to version control. Add .env to your .gitignore.

Config File (config.json)

The config.json file defines test execution and repository handling settings. This configures how the oracle server clones, builds, and tests repositories.

Purpose:

  • Configure repository URLs and build commands for test execution
  • Set execution timeouts and security constraints
  • Define isolated execution environment parameters

Create config.json with:

{
  "repositories": {
    "source": {
      "url": "https://github.com/user/solution.git",
      "branch": "main",
      "buildCommand": "bun install",              // Command to install dependencies
      "testCommand": "bun test",                  // Command to run tests
      "installCommand": "bun install"             // Alternative install command
    },
    "testcase": {
      "url": "https://github.com/user/tests.git",
      "branch": "main", 
      "buildCommand": "bun install",
      "testCommand": "bun test",
      "installCommand": "bun install"
    }
  },
  "execution": {
    "timeout": 300000,                            // 5 minutes timeout for test execution
    "cleanupAfterExecution": true,                // Remove temp files after tests
    "isolatedEnvironment": true,                  // Run in sandboxed environment
    "tempDirectory": "./temp",                    // Directory for temporary files
    "maxMemoryMB": 512,                          // Memory limit for test execution
    "allowedCommands": ["bun", "npm", "yarn", "pnpm", "cargo", "go"] // Whitelist of allowed commands
  },
  "security": {
    "enableNetworkAccess": false,                 // Block network access during tests
    "restrictFileSystem": true,                   // Limit file system access
    "timeboxExecution": true                      // Enforce strict timeouts
  }
}

Configuration Usage Examples

# Use default config.json for oracle server
./bin/git-escrows server --port 3000

# Use custom configuration file
./bin/git-escrows server --port 3000 --config ./custom-config.json

# Generate .env file interactively
./bin/git-escrows new-client --privateKey 0x... --network sepolia

Security Features

  • Cryptographic Commit Verification: Multi-algorithm support (SHA-1, SHA-256, MD5)
  • Key Type Detection: Automatic SSH/PGP/X.509 key format detection
  • Isolated Execution: Sandboxed test execution environment
  • Blockchain Verification: Smart contract-enforced escrow rules
  • Multi-signature Support: Arbiter and oracle verification patterns

Network Support

  • Local Development: Anvil, Localhost
  • Testnets: Sepolia, Goerli
  • Mainnet: Ethereum mainnet

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes with signed commits
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Development Guidelines

  • All commits must be signed (SSH/PGP)
  • Add tests for new features
  • Follow TypeScript best practices
  • Update documentation for API changes

License

MIT License - see LICENSE for details.

Troubleshooting

Common Issues

  1. Key Registration Fails

    • Ensure Git is configured with your key
    • Verify key format with --verbose flag
    • Check network connection and gas fees
  2. Test Execution Timeouts

    • Increase timeout in config.json
    • Check repository accessibility
    • Verify build/test commands
  3. Binary Build Issues

    • Update Bun to latest version
    • Clear node_modules and reinstall
    • Check target platform compatibility

For more help, check the test files in tests/ directory for usage examples.


Built with care using Bun, TypeScript, and Ethereum smart contracts.

About

Peer to peer trading of Git commits, with automatic escrow release based on test suites

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •