Documentation
API reference, smart contract interface, and quick-start guides for the Smainer protocol.
Implementation Guide
For Demanders (submit tasks)
1. Connect your Starknet wallet (Argent X or Braavos).
2. Navigate to Tasks → Submit and fill in the task payload and resource requirements.
3. Approve the ERC-20 token spend when prompted.
4. Confirm the transaction — your task is now on-chain and will be assigned to a provider.
5. Monitor status on the Tasks page. Results appear once the provider submits proof.
For Providers (earn tokens)
1. Install the provider daemon: pip install -e . in the provider/ directory.
2. Set environment variables (wallet key, relayer URL, node ID).
3. Register your node on-chain via the /providers page.
4. Run provider-daemon — the daemon connects via WebSocket and starts receiving tasks.
Relayer API
The Relayer accepts HTTP requests and manages WebSocket connections. Authenticated endpoints require anAuthorization: Bearer <api-key> header.
/api/v1/tasks
Submit a compute task to the network
/api/v1/tasks/{task_id}
Get status and results of a specific task
/api/v1/nodes
List all active compute provider nodes
/api/v1/nodes/{node_id}
Get detailed info about a specific node
/api/v1/health
Health check — returns service status and uptime
/api/v1/stats
Network statistics — total nodes, tasks, throughput
Example: Submit a Task
curl -X POST https://relayer.smainer.io/api/v1/tasks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payload": {
"algorithm": "matrix_multiplication",
"matrix_a": [[1,2],[3,4]],
"matrix_b": [[5,6],[7,8]]
},
"requirements": {
"cpu_threads": 4,
"ram_gb": 8,
"gpu_required": false,
"max_execution_time": 300
},
"token_amount": 1000,
"description": "Matrix multiplication"
}'WebSocket Protocol
Provider nodes connect via WebSocket at ws://relayer/ws/node/<node_id>. Messages are JSON-encoded with a message_type field.
register — Node sends hardware specs and address on connection.
heartbeat — Node sends CPU/memory usage every 30s.
task_assignment — Relayer pushes a task to the node.
task_result — Node sends computation output + signature.
Smart Contract Interface
Cairo contracts deployed on Starknet. All fee calculations use basis points (BPS_DENOMINATOR = 10000).
create_task
Create a new compute task with escrowed ERC-20 payment
cancel_task
Cancel a task and refund escrowed tokens (if not yet assigned)
register_node
Register the caller as a compute provider
submit_proof_and_claim
Submit computation proof and trigger automatic payment split
get_task
Read task details by ID — creator, provider, amount, status, hashes
get_user_tasks
List task IDs for a given user address (paginated)
get_user_earnings
Total accumulated earnings for a provider address
get_node_status
Current status of a registered provider node