Swan Chain
  • BULDERS
    • Getting Started
    • DApp Developer
      • Deploying Your First Smart Contract with Remix
      • Interacting with Smart Contract on Swan Chain Using Go
    • App Developer
      • Building Docker Images and Deployment file with LDL
        • Lagrange Definition Language(LDL)
      • Deploying with Swan SDK
      • Store and Retrieve a File with Swan Storage
        • 1. Set up the python-MCS-SDK
        • 2.Create and Manage Buckets
        • 3.Upload Files and Folders
        • 4.Retrieve and Download Files
        • 5.Delete Files and Buckets
    • Node Operator
      • Swan Node Snapshots
    • Market Provider
      • Storage Market
      • AI/ML Orchestrator
        • Decentralized AI Marketplace
        • Connect to Orchestrator
      • Web3 ZK Computing Market
        • ZK Auction Engine
        • Sequencer
        • Contribute zk-UBI-task
          • How to Contribute
        • Example
      • Customized Market Provider
    • Computing Provider
      • Fog Computing Provider(FCP)
        • FCP Setup
        • Migrating FCP to Swan Mainnet
        • FCP Funding Operations Guide
        • FCP FAQ
      • Edge Computing Provider (ECP)
        • ECP Setup
        • ECP Funding Operations Guide
        • ECP FAQ
      • FAQ
    • Storage Provider
      • Storage Auction System
    • Developer Tools
      • Swan SDK
        • Python Swan SDK
          • Special Case: Create ssh login instance
          • SWAN Orchestrator SDK - Function and Parameter Reference
        • Go Swan SDK
          • A Sample Tutorial
      • Swan Console
        • Getting Started
        • Blockchain GPU Task Example
        • Custom Blockchain GPU Task Pools
      • Lagrange
      • Swan IPFS Storage
      • Nebula Block Cloud
      • Ecosystem Projects
    • Mission 3.0
      • Get Started
        • For Users
        • For Space Holders
  • NETWORK REFERENCE
    • Network Info
      • Set Up Your Wallet
      • Bridge Token
    • Contract Addresses
    • Fees
  • Core Concepts
    • Introduction to Swan Chain
    • Consensus Layer
    • Peer-to-peer (P2P) Network
    • Payment Channels
    • Service Discovery
    • Market Provider
      • Storage Market
      • AI Computing Marketplace
        • Orchestrator
        • Auction Engine
        • Bidding Task State Machine
      • ZK Proof Marketplace
        • ZK Task
        • ZK Pool
    • Storage Layer
    • Computing Layer
      • Computing Provider Protocol
      • Computing Provider Account
      • Layer3 Computing Protocol
      • Reputation System
      • Dynamic Pricing
    • CDN Layer
    • Tokenomics
      • UBI Allocation Curve
      • Computing Provider Income
      • Computing Provider Collateral
        • Collateral Requirement and Computing Unit
        • DePIN Oracle
      • Governance
        • Treasure DAO
    • Glossary
  • Swan Chain Campaign
    • Swan CP UBI
    • Swan Chain Mainnet
      • Network Information
      • Swan Token
      • Swan Chain Mission
        • Social Mission
        • Onchain Mission
        • Mission: Celestial Bloom
      • Swan Provider Campaign
        • Fog Computing Provider (FCP)
        • Edge Computing Provider (ECP)
        • Market Provider (MP)
      • GALXE Campaign
      • Free Tier and Special Credit Programs
    • Atom Accelerator Race
      • Before You Get Started
        • Set Up MetaMask
        • Claim SepoliaETH
        • Claim testSWAN
      • CP Acceleration Program
      • Builder Acceleration Program
      • On-chain Interaction Race
      • Community Engagement Challenge
      • FAQ
    • Swan Saturn Testnet
      • Before You Get Started
        • Set Up MetaMask
        • Claim Faucet Tokens
        • Bridge Tokens
      • Transaction Drive Program
      • Community and Educational Events
      • Partnership and Integration Program
      • KOL Program
      • Computing Provider Program
        • FAQ
      • Developer Grant Program
      • FAQ
    • Swan Jupiter Testnet
      • How to Participate
      • Before You Get Started
      • Network Early Adopter
      • FAQ
  • RESOURCE
    • Links
    • Brand Kit
Powered by GitBook
On this page
  • Overview
  • Features
  • Source Code
  • Summary
  1. Core Concepts
  2. Computing Layer

Computing Provider Account

Overview

CPAccount is a smart contract account based on Swan Chain, designed for managing and registering computing providers (CP). Each computing provider that connects to Swan Chain must create a unique account. When an account is created, the CPAccount automatically registers with the CP Account Register Contract.

Features

The contract account provides a range of functions, including ownership management, worker and beneficiary information management, task type updates (supporting extension for additional task types), and multi-address updates. The contract also includes an event mechanism to notify external systems about changes in ownership, worker, multi-address, and task types.

Key Functions

  • Ownership Management: Allows the owner to change the contract's owner address.

  • Worker Management: Allows the owner to change the worker address.

  • Beneficiary Management: Allows the owner to change the beneficiary address.

  • Multi-address Management: Allows the owner to update the multi-address array.

  • Task Type Management: Allows the owner to update the task type array, supporting extension for additional task types.

Account Roles

To ensure the security of the CP Account, the roles are categorised into:

  • Owner: Manages the CP Account and has permission to change account information such as multi-addresses, worker address, and beneficiary address. The private key of the owner's address does not need to be present on the server for security reasons.

  • Worker: This address is used for submitting task results and needs to be funded with a certain amount of ETH to pay for gas fees.

  • Beneficiary: This address receives all earnings from the CP Account and is solely used for receiving funds. For security purposes, the private key of the beneficiary's address should not be stored on the server to maintain isolation.

Event Mechanism

  • OwnershipTransferred: Ownership transfer event, notifying external systems of changes in the owner address.

  • WorkerChanged: Worker change event, notifying external systems of changes in the worker address.

  • MultiaddrsChanged: Multi-address change event, notifying external systems of changes in multi-addresses.

  • BeneficiaryChanged: Beneficiary change event, notifying external systems of changes in the beneficiary address.

  • TaskTypesChanged: Task type change event, notifying external systems of changes in task types.

  • CPAccountDeployed: CPAccount deployment event, notifying external systems of the creation and registration of the CPAccount.

Token Flow Diagram

Workflow

  1. Registration:

    • A new CP deploys the CPAccount contract with the required parameters.

    • The CP is registered with the Contract Registry.

  2. Task Assignment and Execution:

    • Tasks are assigned to the CP by the AI or ZK engines.

    • CP locks the required collateral before starting task execution.

    • Upon task completion, the CP is rewarded, and collateral is released.

  3. Collateral Management:

    • Collateral is locked before task execution and released upon successful completion.

    • In case of task failure, collateral is slashed as a penalty.

  4. Deposits and Withdrawals:

    • CPs can deposit tokens into their accounts to maintain sufficient balance for collateral.

    • Withdrawal requests can be made and confirmed after a delay period.

Source Code

Summary

The CPAccount contract provides a robust framework for managing and registering computing providers on Swan Chain. It facilitates secure management of ownership, worker, and beneficiary roles, with flexible support for extending task types. Through its comprehensive functionality and event-driven architecture, it ensures transparency and security in CP Account operations.

PreviousComputing Provider ProtocolNextLayer3 Computing Protocol

Last updated 9 months ago

Detailed source code for the CPAccount contract can be found .

here