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
  1. Core Concepts

Payment Channels

The Swan Chain Payment Channels are designed to provide an efficient, low-cost, and secure mechanism for payments between clients and computing providers (CPs) within the Swan Chain ecosystem. Leveging smart contracts, these channels enable seamless micropayments and larger transactions without requiring every individual payment to be processed directly on-chain, reducing costs and increasing scalability.


Overview of Swan Chain Payment Channels

Payment Channels allow clients and providers to exchange payments off-chain, which are only settled on-chain when the channel is closed. This approach reduces the need for each transaction to be processed on the blockchain, resulting in significant cost savings and increased transaction speed. Swan Chain Payment Channels operate within the ecosystem to pay for computing resources, AI model training, storage, and other services.


How Payment Channels Work

  1. Opening a Payment Channel:

    • The client and computing provider open a payment channel by locking funds in a smart contract. The client locks a certain amount of Swan tokens will be used to pay for the services rendered by the provider.

    • This amount represents the total prepaid balance available for the provider, ensuring that the funds are reserved and can be released automatically upon completion of the job.

  2. Off-Chain Payments:

    • Once the payment channel is established, the client and provider can make multiple payments off-chain without involving the blockchain for each transaction.

    • For each job (e.g., AI computation, data storage), the client sends a signed payment update to the provider, specifying the amount to be paid for that job. These signed updates are cryptographically secured but are not submitted on-chain until the channel is closed.

  3. Challenge Period:

    • After the provider completes the job, a challenge period is triggered, during which the client can verify the quality and completion of the task.

    • If no disputes or challenges arise during this period, the payment update is considered valid, and the funds are automatically transferred from the client to the provider.

  4. Closing the Payment Channel:

    • When the client or provider decides to close the payment channel, the final state (i.e., the total amount paid) is posted to the blockchain. This triggers the settlement process, where the remaining funds are returned to the client, and the provider is paid for all completed jobs.

    • Only the final transaction (closing the channel) is recorded on-chain, reducing transaction costs.

  5. Collateral and Slashing (In Case of Failure):

    • If the provider fails to complete the job or the client raises a successful challenge, the provider’s collateral (locked in a CPAccount) is slashed, and the client is refunded for the incomplete job.


Payment Channel Flow:

Stage

Description

1. Channel Opening

Client and provider open a channel by locking funds in a smart contract. These funds are used to pay for services over the duration of the channel.

2. Off-Chain Payments

The client sends signed payment updates to the provider for each completed job. These transactions happen off-chain, reducing gas fees.

3. Job Completion & Challenge

Upon job completion, a challenge period allows the client to verify the results. If no challenge is raised, payments proceed automatically.

4. Channel Closing

When the channel is closed, the final transaction is recorded on-chain, distributing the funds to the provider and refunding any remaining balance.

5. Collateral Slashing

If the provider fails to complete the job, their collateral is slashed, and the client is refunded for the incomplete or faulty service.


Key Features of Swan Chain Payment Channels

  1. Cost-Efficiency:

    • By conducting transactions off-chain and settling only the final payment on-chain, Swan Chain’s payment channels drastically reduce gas fees and transaction costs, making it ideal for frequent micropayments.

  2. Scalability:

    • Payment channels allow for a large number of transactions to occur off-chain, making the system highly scalable and capable of handling many clients and providers with minimal blockchain congestion.

  3. Trustless and Automated Payments:

    • Payments are secured through smart contracts and are only released after successful job completion, making the system trustless and ensuring fairness for both parties.

  4. Flexibility:

    • Multiple jobs can be paid for through a single payment channel, and both small micropayments and larger transactions are supported. The payment channels can be closed when needed, providing flexibility in managing ongoing tasks and services.

  5. Security:

    • All off-chain payment updates are cryptographically secured, and the final settlement is verified on-chain. Additionally, provider collateral ensures that providers are financially incentivized to complete their jobs correctly.


Use Cases for Swan Chain Payment Channels

  1. AI Computing and Model Training:

    • Clients can pay providers for AI model training or inference tasks by submitting payments as jobs are completed, without incurring high transaction fees for each job.

    • Providers are guaranteed payment through the payment channel, allowing them to focus on delivering high-quality computational results.

  2. Decentralized Storage:

    • Clients can store data on Swan Chain’s decentralized storage network and pay for storage space as they use it, without requiring frequent on-chain transactions.

    • Payment channels enable real-time payments for storage use, with the added security of smart contract guarantees.

  3. Streaming and Content Delivery:

    • Content providers can use payment channels to collect payments for decentralized streaming services or content delivery, ensuring that payments are automated and gas fees are minimized.

  4. Recurring Payments for dApps:

    • Payment channels are ideal for subscription-based services or decentralized applications (dApps) that require recurring payments, such as gaming, content access, or cloud services.


How to Open and Use a Payment Channel on Swan Chain

  1. Step 1: Open a Payment Channel

    • Both the client and the provider agree to lock a certain amount of Swan tokens in the payment channel smart contract.

    • This locks the funds for the duration of the channel, ensuring that payments can be made without additional on-chain transactions.

  2. Step 2: Off-Chain Payments for Jobs

    • As the provider completes jobs, the client sends signed payment updates to the provider. These payment updates reflect the amount owed for each task and are stored off-chain.

  3. Step 3: Verify Job Completion

    • After the provider finishes a job, the client enters a challenge period to verify that the job was completed correctly.

    • If no challenges are raised, the payment update is accepted, and the funds are released from the payment channel.

  4. Step 4: Close the Payment Channel

    • When either party wants to settle the account, they close the payment channel by submitting the final state of payments to the blockchain.

    • The smart contract automatically settles the balance, paying the provider and refunding any unused funds to the client.


Benefits of Payment Channels for Clients and Providers

  1. Clients:

    • Lower Fees: By minimizing on-chain transactions, clients save on gas fees and can make multiple payments without the burden of high costs.

    • Real-Time Payments: Clients can pay for completed jobs in real-time, ensuring they only pay for what is delivered.

    • Security: Funds are locked in smart contracts, guaranteeing that payments are handled automatically and transparently.

  2. Providers:

    • Guaranteed Payment: Providers are guaranteed payment for completed jobs through the payment channel system, reducing the risk of non-payment.

    • Incentive to Complete Jobs: Collateral mechanisms ensure that providers are financially incentivized to deliver high-quality results.

PreviousPeer-to-peer (P2P) NetworkNextService Discovery

Last updated 7 months ago