AI Services Documentation
FractalAI provides decentralized AI inference, training, and cross-chain oracle services powered by fractal compression and the golden ratio.
Overview
The FractalAI network enables any blockchain to access AI capabilities through its distributed compute infrastructure. Key components:
FANE Engine
On-chain neural engine supporting Dense, Transformer, CNN, and RL architectures. Uses 4-bit PhiTensor quantization (16x compression via golden ratio quantization table).
Federated Training
FedPhiAvg aggregation distributes model training across nodes. Gradient gossip with QFC compression and phi-weighted age decay. Anti-poisoning via median absolute deviation filtering.
Cross-Chain Oracle
Any EVM chain can request AI inference via the FractalAIOracle contract. Results delivered via bridge relayer. 0.16% phi-based fee.
Model Marketplace
Register models on-chain with versioning and pricing. Revenue split: 61.8% creator, 38.2% compute nodes (golden ratio). Inference fees in FRAI tokens.
RPC Endpoints
Access AI services via JSON-RPC. Default port: 9944.
// Request
{
"jsonrpc": "2.0",
"method": "fractal_submitInference",
"params": {
"model_id": "0x2a00...0000",
"input": [1.0, 2.0, 3.0, 4.0]
},
"id": 1
}
// Response
{
"jsonrpc": "2.0",
"result": {
"output": [0.87, 0.13],
"model_type": "Classifier",
"gas_used": 125000
},
"id": 1
}// Request
{
"jsonrpc": "2.0",
"method": "fractal_getInferenceResult",
"params": { "job_id": "0xabc...123" },
"id": 2
}
// Response
{
"jsonrpc": "2.0",
"result": {
"status": "Completed",
"output": [0.87, 0.13],
"gas_used": 125000,
"execution_time_ms": 245
},
"id": 2
}// Request
{
"jsonrpc": "2.0",
"method": "fractal_listModels",
"params": {},
"id": 3
}
// Response
{
"jsonrpc": "2.0",
"result": {
"models": [
{
"id": "0x2a00...0000",
"type": "Classifier",
"input_shape": [4],
"output_shape": [2],
"total_params": 12500000,
"layers": 6
}
],
"total": 1
},
"id": 3
}// Request
{
"jsonrpc": "2.0",
"method": "fractal_getTrainingStatus",
"params": {},
"id": 4
}
// Response
{
"jsonrpc": "2.0",
"result": {
"current_round": 42,
"total_participants": 7,
"total_rounds": 42,
"total_updates": 294,
"global_loss": 0.0234,
"aggregation_type": "FedPhiAvg"
},
"id": 4
}// Request
{
"jsonrpc": "2.0",
"method": "fractal_getNodeComputeStats",
"params": {},
"id": 5
}
// Response
{
"jsonrpc": "2.0",
"result": {
"total_tasks": 1284,
"open_tasks": 76,
"completed_tasks": 1196,
"fane_models": 3,
"sync_chunks_available": 128,
"sync_versions": 2
},
"id": 5
}Cross-Chain Integration (Solidity)
Use the FractalAIOracle contract deployed on all 7 bridged EVM chains to request AI inference from your smart contracts.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IFractalAIOracle {
function requestInference(
bytes32 modelId,
bytes calldata input
) external payable returns (uint256 requestId);
function getResult(
uint256 requestId
) external view returns (bytes memory result, bool completed);
function isCompleted(
uint256 requestId
) external view returns (bool);
event InferenceCompleted(
uint256 indexed requestId,
bytes32 indexed modelId,
bytes result
);
}
// Example: AI-powered price prediction oracle
contract AIPriceOracle {
IFractalAIOracle public fractalOracle;
bytes32 public constant PRICE_MODEL = 0x2a00...;
constructor(address _oracle) {
fractalOracle = IFractalAIOracle(_oracle);
}
function requestPricePrediction(
bytes calldata priceHistory
) external payable returns (uint256) {
return fractalOracle.requestInference{value: msg.value}(
PRICE_MODEL,
priceHistory
);
}
function getPrediction(
uint256 requestId
) external view returns (bytes memory, bool) {
return fractalOracle.getResult(requestId);
}
}Architecture
Inference Flow
User/Contract Bridge Relayer FractalAI Network
| | |
|-- requestInference() ------->| |
| (payment + modelId + input)| |
| |-- CrossChainAIJob ---->|
| | |-- ComputeProtocol
| | | (scheduler assigns)
| | |-- FANE Engine
| | | (runs inference)
| |<-- result -------------|
|<-- fulfillInference() -------| |
| | |
|-- getResult() ------------->| |
|<-- (output, completed) -----| |Federated Training Flow
Coordinator Node A Node B Node C
| | | |
|-- start_round() -------->| | |
|-- start_round() ---------|------------------>| |
|-- start_round() ---------|-------------------|------------------>|
| | | |
| |-- local training |-- local training |-- local training
| | (FANE engine) | (FANE engine) | (FANE engine)
| | | |
|<-- compressed gradient ---| | |
|<-- compressed gradient ---|-------------------| |
|<-- compressed gradient ---|-------------------|-------------------|
| | | |
|-- FedPhiAvg aggregate | | |
| (phi-weighted) | | |
| | | |
|-- updated weights ------->| | |
|-- updated weights ---------|------------------>| |
|-- updated weights ---------|-------------------|------------------>|Key Constants (Golden Ratio)
Model Registration
Register models on the FractalAI Model Registry for discovery and monetization.
// Models are registered through on-chain transactions
// or via the admin dashboard at /admin/ai
// Architecture types supported:
// - Transformer { num_heads, num_layers, d_model }
// - CNN { channels, kernel_sizes }
// - MLP { hidden_dims }
// - ReinforcementLearning { state_dim, action_dim }
// - Custom(name)
// Revenue split (automatic):
// - 61.8% to model creator (golden ratio)
// - 38.2% to compute nodes
// - 0.16% protocol fee (61.8% of which is burned)
// Pricing: Set by creator in FRAI tokens per inference call
// Version management: Increment via update_version()
// Accuracy tracking: Updated via training verification proofs