CyxWiz LogoCyxWiz
DocsPayment Flow

Payment Flow

Complete documentation of the CyxWiz payment system from job submission to settlement.

Payment Architecture

+------------------+                                    +------------------+
|  CyxWiz Engine   |                                    |   Server Node    |
|     (Client)     |                                    |    (Provider)    |
+--------+---------+                                    +--------+---------+
         |                                                       |
         | 1. Submit Job + Create Escrow                         |
         v                                                       |
+--------+---------+                                             |
| Central Server   |                                             |
+--------+---------+                                             |
         |                                                       |
         | 2. Verify Escrow on Solana                            |
         |                                                       |
         | 3. Assign Job to Node                                 |
         +------------------------------------------------------>|
         |                                                       |
         |<------------------------------------------------------+
         | 4. Job Accepted                                       |
         |                                                       |
         |                         5. Execute Training           |
         |                                                       |
         |<------------------------------------------------------+
         | 6. Report Completion + Proof                          |
         |                                                       |
         | 7. Verify & Release Escrow                            |
         |                                                       |
         +------------------------------------------------------>|
         |                              8. Payment Received      |

Payment Lifecycle

Phase 1: Job Submission
  1. Estimate Cost: Based on model complexity, dataset size, training duration, and required hardware
  2. Create Escrow: Client creates escrow transaction on Solana with payment amount
  3. Submit Job: Job configuration and escrow signature sent to Central Server
  4. Verify Escrow: Server confirms escrow is funded and amount matches quote
Phase 2: Job Assignment
  1. Find Node: Match job requirements to available compute nodes
  2. Lock Escrow: Escrow locked to assigned node's wallet address
  3. Send Assignment: Job config, dataset location, and auth token sent to node
  4. Node Accepts: Node validates and begins execution
Phase 3: Completion & Payment
  1. Generate Proof: Node creates completion proof with model hash and metrics
  2. Upload Results: Model weights uploaded to IPFS/storage
  3. Verify Completion: Server validates model hash and metrics
  4. Release Escrow: Payment distributed to node (90%) and platform (10%)

Escrow Contract

#[account]
pub struct JobEscrow {
    pub job_id: [u8; 32],          // Job identifier
    pub payer: Pubkey,             // Client wallet
    pub payee: Pubkey,             // Node wallet (set on lock)
    pub platform: Pubkey,          // Platform treasury
    pub amount: u64,               // Payment amount
    pub token_mint: Pubkey,        // CYXWIZ token mint
    pub status: EscrowStatus,      // Current status
    pub created_at: i64,           // Creation timestamp
    pub locked_at: i64,            // Lock timestamp
    pub expires_at: i64,           // Expiration timestamp
    pub bump: u8,                  // PDA bump
}

#[derive(Clone, Copy, PartialEq)]
pub enum EscrowStatus {
    Created,    // Funds deposited
    Locked,     // Job assigned to node
    Released,   // Payment completed
    Refunded,   // Returned to client
    Disputed,   // Under arbitration
    Expired,    // Past expiration
}

Escrow Operations

Create Escrow
pub fn create_escrow(
    ctx: Context<CreateEscrow>,
    job_id: [u8; 32],
    amount: u64,
    expiration: i64,
) -> Result<()>;

// Called by client when submitting job
Lock Escrow
pub fn lock_escrow(
    ctx: Context<LockEscrow>,
    job_id: [u8; 32],
    node_wallet: Pubkey,
) -> Result<()>;

// Called by server when assigning job
Release Escrow
pub fn release_escrow(
    ctx: Context<ReleaseEscrow>,
    job_id: [u8; 32],
) -> Result<()>;

// Called by server after verification
Refund Escrow
pub fn refund_escrow(
    ctx: Context<RefundEscrow>,
    job_id: [u8; 32],
) -> Result<()>;

// Called on cancellation or failure

Pricing Model

FactorWeightDescription
GPU HoursHighPrimary cost driver
Model ParametersMediumMemory/compute requirements
Dataset SizeLowTransfer/storage costs
PriorityMultiplier1x normal, 2x high, 3x critical
# GPU Rate Multipliers
gpu_multipliers = {
    'RTX_3060': 1.0,
    'RTX_3080': 1.5,
    'RTX_4090': 3.0,
    'A100': 5.0,
}

# Example: RTX 4090 for 2 hours at high priority
price = base_rate * 2 * 3.0 * 2 * 1.1  # = 13.2x base rate

Transaction Costs

OperationApproximate Cost
Create Escrow~0.002 SOL
Lock Escrow~0.0001 SOL
Release Escrow~0.0001 SOL
Refund Escrow~0.0001 SOL

Failure Handling

Job Failure
Node reports failure with reason. Escrow refunded to client minus gas. Node reputation affected if fault is theirs.
Node Disconnection
Missed heartbeats detected. Job marked abandoned. Escrow unlocked and job reassigned to another node.
Timeout
Job exceeds duration limit. Partial refund to client, partial payment to node for completed work.

Security Considerations

  • Escrow Ownership: Only Central Server authority can lock/release escrows
  • Expiration: Clients can reclaim funds after timeout if job not completed
  • No Front-Running: Job assignment happens off-chain, preventing MEV attacks
  • Proof of Compute: Future: cryptographic verification of completed work
  • Stake Slashing: Future: nodes lose stake for malicious behavior