Institutional Settlement Specification
The definitive technical standard for the SkillRail work settlement protocol. This document is the source of truth for the system's architecture and logic.
1. Core Architecture
Design Philosophy
SkillRail is an institutional-grade settlement standard designed to eliminate the 'Trust Tax' in labor markets. It uses a Clean Architecture pattern, isolating pure business rules (Domain) from platform-specific infrastructure.
Key Principles
- Deterministic Finality: On-chain state transitions govern the entire job lifecycle.
- Universal Agnosticism: Behavioral parity across Docker, Mac, and Linux environments.
- Non-Custodial Security: PDAs act as sovereign vaults, ensuring assets are protected by cryptographic logic.
System Integrity
- Instruction-Logic Separation: lib.rs delegates to logic.rs for pure rule validation.
- Isolated Vaults: Each job uses a program-controlled vault for asset separation.
- Strict Account Checks: Deterministic PDA verification for every mutation.
2. The Work State Machine
Lifecycle Transitions
The protocol enforces a strict directional flow to ensure contract compliance.
| Source State | Target State | Authorized Actor | Outcome |
|---|---|---|---|
| None | Created | Requester | Terms defined on-chain |
| Created | Funded | Requester | Assets locked in vault |
| Funded | Submitted | Provider | Result metadata reference stored |
| Submitted | Completed | Requester | Atomically settled & paid |
| Funded | Refunded | Requester | Recovery after deadline expiry |
Invariant Rules
- Jobs must be 'Funded' before work submission.
- Payouts are atomic and requires requester acceptance.
- Refunds only trigger after deadline + Funded status.
3. Account Memory Layout
ProviderProfile (253 Bytes)
Stores technical identity and reputation markers.
| Field | Type | Bytes | Description |
|---|---|---|---|
| authority | Pubkey | 32 | The provider's wallet |
| metadata_uri | String | 204 | Identity payload (Max 200 chars) |
| created_at | i64 | 8 | Timestamp |
| bump | u8 | 1 | PDA derivation bump |
Job (547 Bytes)
The authoritative record of a work settlement contract.
| Field | Type | Bytes | Description |
|---|---|---|---|
| requester | Pubkey | 32 | Funding party |
| provider | Pubkey | 32 | Executing party |
| mint | Pubkey | 32 | Settlement asset (e.g. USDC) |
| amount | u64 | 8 | Escrow volume |
| status | Enum | 1 | Current machine state |
| deadline_at | i64 | 8 | Expiry timestamp |
| terms_uri | String | 204 | Agreement reference |
| result_uri | String | 204 | Delivery reference |
Sizing Strategy
All string fields are strictly bounded to ensuring predictable account rent costs. Metadata URIs (metadata, terms, result) are limited to 200 characters each.
4. Instruction Specification
register_provider
Initializes a provider profile. Precondition: metadata_uri.len() <= 200 bytes.
| Account | Type | Signer |
|---|---|---|
| provider | Signer | Yes |
| profile | PDA | No |
| system_program | Program | No |
create_job
Initializes a Job PDA. Requires: valid assigned provider profile, amount > 0, and future deadline.
| Input | Type | Notes |
|---|---|---|
| job_id | u64 | Unique per requester |
| amount | u64 | Base units |
| deadline_at | i64 | Unix timestamp |
fund_job
Escrows assets from Requester to Job Vault. Atomic CPI transfer ensures status only moves to 'Funded' on success.
submit_result
Provider commits work. Valid only if Funded and before deadline.
accept_result
Requester finalizes the job. Triggers atomic payout from Vault to Provider.
refund_job
Recovery path. Valid only if Funded and Clock > deadline_at.
Technical Table
| Instruction | Signer | State Change |
|---|---|---|
| register_provider | Provider | Init Profile |
| create_job | Requester | Init PDA |
| fund_job | Requester | Lock Assets |
| submit_result | Provider | Link Result |
| accept_result | Requester | Payout |
| refund_job | Requester | Recover |
5. SDK & Integration Layer
SkillRailClient
The high-level entry point for all frontends and services. Encapsulates RPC complexity, PDA derivation, and transaction building.
Domain Entities
Rich objects like 'JobEntity' provide off-chain utility methods (isFunded, canRequesterRefund) ensuring business logic remains consistent.
Code Snippet
const client = new SkillRailClient(program); const job = await client.getJob(address);
6. Multi-Network Strategy
Transition Matrix
| Cluster | RPC Endpoint | Official USDC Mint |
|---|---|---|
| Localhost | http://localhost:8899 | Dynamic (via setup) |
| Devnet | https://api.devnet.solana.com | 4zMMC9srt5Ri5TQJEUveajzQXWvDvcNth7S4V9BXXm6N |
| Mainnet | https://api.mainnet-beta.solana.com | EPjFW36vS7ox6re7FLUvHA7L6z5HKu39wjLzerjhcLhH |
7. Protocol Validation Logic
Strict Security Checks
The protocol centralizes security logic into dedicated validation modules to prevent bypass attacks.
- ACCOUNT_OWNERSHIP: Verified via Anchor's #[account] macros.
- SIGNATURE_AUTHORITY: Every mutation requires a multi-signer proof.
- TOKEN_MINT_ENFORCEMENT: Only authorized settlement assets are accepted.
- PDA_CANONICAL_CHECK: Bumps are validated to prevent account spoofing.
8. Technical Repository Map
Monorepo Structure
SkillRail follows a unified monorepo pattern for behavioral parity across layers.
- /contracts: Authoritative Rust source of truth.
- /sdk: TypeScript bridge for RPC orchestration.
- /web: Next.js operator dashboard.
- /tests: High-assurance protocol test suite.
9. Protocol Security Model
High-Assurance Integrity
SkillRail enforces security through deterministic isolation.
- Isolated Vaults: Each job uses a unique PDA-controlled ATA.
- Canonical Verification: Forced bump validation prevents spoofing.
- Signer Constraints: Multi-party verification for every state jump.
10. System Design & DDD
Architectural Philosophy
Built on Domain-Driven Design (DDD) to isolate business invariants from blockchain infrastructure.
- Pure Domain Logic: Rust modules for pure transition rules.
- Agnostic SDK: Repository patterns for RPC orchestration.
- Operator Dashboard: Feature-sliced presentation layer.
11. Global Error Registry
Program Exceptions
Authoritative reference for on-chain error codes.
| Code | Description | Resolution |
|---|---|---|
| InvalidDeadline | Timestamp in past | Use future unix time |
| DeadlineExceeded | Work submitted late | Refund path active |
| UriTooLong | Metadata > 200B | Compress metadata string |