A verifiable, private, and autonomous perpetual futures exchange running in Intel TDX enclaves via EigenCompute, with on-chain attestation anchored to Ethereum Sepolia.
Private Perps is a decentralized perpetual futures exchange that:
- Executes trades privately inside TEE enclaves
- Generates verifiable attestations for every state transition
- Anchors state roots to Ethereum for transparency
- Operates autonomously without centralized control
- Provides non-custodial trading with cryptographic guarantees
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EigenCompute TEE β
β βββββββββββββ ββββββββββββ ββββββββββββββββββ β
β β Matching ββββ Price ββββ Attestation β β
β β Engine β β Oracle β β Service β β
β βββββββββββββ ββββββββββββ ββββββββββββββββββ β
β β β β β
β βββββββββββββ ββββββββββββ β β
β β OrderBook β β REST/WS β β β
β β β β API β β β
β βββββββββββββ ββββββββββββ β β
ββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββ
β
Attestations
β
βΌ
ββββββββββββββββββββββββ
β Ethereum Sepolia β
β ββββββββββββββββββ β
β β EigenVerify β β
β β Contract β β
β ββββββββββββββββββ β
ββββββββββββββββββββββββ
- Node.js β₯ v18
- Docker Desktop
- Sepolia ETH (for contract deployment)
- EigenX CLI access (request at eigenx.ai)
# Clone repository
git clone https://github.com/yourusername/private-perps
cd private-perps
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Deploy smart contracts to Sepolia
npx hardhat run scripts/deploy.ts --network sepolia
# Run locally
npm run dev# Authenticate with EigenX
eigenx auth generate --store
# Deploy to TEE
eigenx app deploy
# View deployment status
eigenx app infoEdit .env with your credentials:
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
PRIVATE_KEY=your_deployment_wallet_private_key
ETHERSCAN_API_KEY=your_etherscan_api_key# Compile contracts
npx hardhat compile
# Deploy to Sepolia
npx hardhat run scripts/deploy.ts --network sepolia
# Verify on Etherscan (automatic if API key provided)After deployment, update .env:
EIGEN_VERIFY_CONTRACT=0x... # Deployed contract address
ENCLAVE_SIGNER_ADDRESS=0x... # From eigenx auth whoami| Variable | Description | Default |
|---|---|---|
EXCHANGE_NAME_PUBLIC |
Exchange name | Private Perps |
MAX_LEVERAGE |
Maximum trading leverage | 20x |
LIQUIDATION_PENALTY |
Liquidation fee percentage | 2.5% |
ATTESTATION_INTERVAL_SECONDS |
Attestation frequency | 300 (5 min) |
| Variable | Description | Default |
|---|---|---|
APP_PORT |
REST API port | 8000 |
WS_PORT |
WebSocket port | 8001 |
ENABLE_REST_API |
Enable REST endpoints | true |
ENABLE_WEBSOCKET |
Enable WebSocket server | true |
GET /api/v1/orderbook/:symbol- Get order bookGET /api/v1/trades/:symbol- Recent tradesGET /api/v1/ticker/:symbol- Price ticker
POST /api/v1/order- Submit orderDELETE /api/v1/order/:orderId- Cancel orderGET /api/v1/orders/:userId- User orders
GET /api/v1/position/:userId- User positionGET /api/v1/positions- All positions
GET /health- Health checkGET /api/v1/status- Engine statusGET /api/v1/attestation- Attestation status
Connect to ws://localhost:8000 and subscribe:
// Subscribe to channels
{ "type": "subscribe", "channel": "trades" }
{ "type": "subscribe", "channel": "orderbook" }
{ "type": "subscribe", "channel": "ticker" }
// Submit orders (requires auth)
{ "type": "auth", "data": { "userId": "user123" } }
{ "type": "submit_order", "data": { ... } }- Memory Encryption: All data encrypted in Intel TDX enclave memory
- Attestation: Cryptographic proof of code integrity
- Isolation: Protected from host OS and hypervisor
- State roots anchored to Ethereum
- Attestations verified by smart contract
- Challenge mechanism for disputes
- Users maintain control of funds
- Enclave only manages trading logic
- Transparent state transitions
# Contract tests
npx hardhat test
# Integration tests
npm test
# Coverage report
npx hardhat coverage- Deploy contracts to Sepolia
- Configure
.envwith testnet settings - Set
USE_TEST_PRICES=truefor mock prices - Run with
npm run dev
eigenx app logs [app-name]# Application status
curl http://localhost:8000/api/v1/status
# Attestation status
curl http://localhost:8000/api/v1/attestation
# Health check
curl http://localhost:8000/healthView attestations on Etherscan:
https://sepolia.etherscan.io/address/[EIGEN_VERIFY_CONTRACT]
npm run dev # Start local server
npm run build # Compile TypeScript
npm test # Run testsdocker build -t private-perps .
docker run --rm --env-file .env private-perpseigenx app deploy
eigenx app logs
eigenx app info# Make changes to code
eigenx app upgradeAttestation Failures
- Check enclave wallet has ETH for gas
- Verify contract address in
.env - Ensure enclave is registered on-chain
Connection Issues
- Verify RPC URL is correct
- Check network connectivity
- Ensure ports are not blocked
Build Failures
- Platform must be
linux/amd64 - Run as root user in Docker
- Check Node.js version β₯ 18
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Commit changes with clear messages
- Submit a pull request
MIT License - see LICENSE file
This is experimental software running in alpha. Use at your own risk. Not audited for production use.
Built with EigenCompute | Secured by Intel TDX | Anchored on Ethereum