Skip to main content

Account

The 0G Compute Network uses a unified account system for managing funds across services. This guide covers how to manage your accounts using different interfaces: Web UI, CLI, and SDK.

Overview

The account system provides a secure and flexible way to manage funds across different AI service providers.

Account Structure

  • Main Account: Your primary wallet where funds are deposited. All deposits go here first, and you can withdraw funds from here back to your wallet.
  • Sub-Accounts: Provider-specific accounts created automatically when you transfer funds to a provider. Each provider has a separate sub-account where funds are locked for their specific services.

Fund Flow

Account Fund Flow Diagram
  1. Deposit: Transfer funds from your wallet to your Main Account
  2. Transfer: Move funds from Main Account to Provider Sub-Accounts
  3. Usage: Provider deducts from Sub-Account for services rendered
  4. Refund Request: Initiate refund from Sub-Account (enters 24-hour lock period)
  5. Complete Refund: After lock period expires, call retrieve-fund again to complete transfer back to Main Account
  6. Withdraw: Transfer funds from Main Account back to your wallet

Security Features

  • 24-hour lock period for refunds to protect providers from abuse
  • Single-use authentication for each request to prevent replay attacks
  • On-chain verification for all transactions ensuring transparency
  • Provider acknowledgment required before first use of services

Prerequisites

  • Node.js >= 22.0.0
  • A wallet with 0G tokens (for testnet or mainnet)
  • EVM compatible wallet (for Web UI)

Choose Your Interface

FeatureWeb UICLISDK
Setup time~1 min~2 min~5 min
Visual dashboard
Automation
App integration

Best for: Quick account management with visual dashboard

Installation

pnpm add @0glabs/0g-serving-broker -g

Launch Web UI

0g-compute-cli ui start-web

Access the Web UI at http://localhost:3090/wallet where you can:

  • View your account balance in real-time
  • Deposit funds directly from your connected wallet
  • Transfer funds to provider sub-accounts
  • Monitor spending and usage
  • Request refunds with a visual interface

Best Practices

For Inference Services

  1. Deposit enough funds for expected usage
  2. Transfer funds to providers you plan to use frequently
  3. Keep some balance in sub-accounts for better response times
  4. Monitor usage regularly

For Fine-tuning Services

  1. Calculate dataset size before transferring funds
  2. Transfer enough to cover the entire training job
  3. Request refunds for unused funds after job completion

Troubleshooting

Insufficient Balance Error

Check which account needs funds:

  • Main account: Use deposit
  • Sub-account: Use transfer-fund
# Check all balances
0g-compute-cli get-account

# Deposit to main account if needed
0g-compute-cli deposit --amount 10

# Transfer to provider if needed
0g-compute-cli transfer-fund --provider <ADDRESS> --amount 5
Refund Not Available

Refunds have a 24-hour lock period. After the lock period expires, you need to call the retrieve-fund function again to complete the refund. Check the status:

0g-compute-cli get-sub-account --provider <PROVIDER_ADDRESS>

Look for "Remaining Locked Time" in the output.

Transaction Failed

Common causes:

  1. Network issues - Check your RPC endpoint
  2. Gas price too low - Increase gas price
  3. Insufficient gas - Ensure wallet has enough for gas fees
# Specify custom gas price
0g-compute-cli deposit --amount 10 --gas-price 20000000000