Swan Network
English
  • Getting Started
    • Overview
    • Protocol Stack
      • Cross-chain Consensus Layer
      • Peer-to-peer (P2P) Network
      • Payment Channels
      • Service Discovery
      • Data Marketplace
      • Indexing and Caching Marketplace
      • Web3 Task Auction
      • Storage Layer
      • Computing Layer
      • CDN Layer
      • Economic System
        • Grants
        • Computing Jobs
        • Universal Basic Income (UBI)
        • Swan Provider Income
      • Token
      • Governance
        • Treasure DAO
      • Glossary
    • Contact Us
      • Social Accounts & Communities
      • Business Partnerships
    • FAQ
  • QuickStarts
    • Dive into QuickStarts
      • Swan Chain: Developing Smart Contracts with Go
  • Swan Storage Market
    • Overview
      • Swan Auction System
      • Reputation System
    • Key functionalities
      • Task Management
        • Create a New Task
        • Navigate Tasks
        • Update Tasks
        • Assign Tasks
      • My Profile
        • Register as a storage provider
      • Find Storage Providers
        • Storage Provider Details
      • Extend DataCap Terms Service
  • Swan IPFS Storage
    • Overview
      • Flink
    • Swan IPFS Storage User Guide
      • Networks
      • Setup MetaMask
    • Developer Quickstart
      • SDK
        • js MCS SDK
          • Prerequisites
          • Get Started
          • Bucket Storage
          • Onchain Storage
          • SDK JS Installation Tutorial Video
        • python MCS SDK
          • Quickstart
          • Bucket Storage
          • Onchain Storage
          • SDK Python Installation Tutorial Video
      • Additional Resources
    • Best Practice
      • Use Swan IPFS Storage as Platform Storage Solution
        • Single Organization Design
        • Multiple Organization Design
    • FAQ
  • Swan Provider
    • Overview
    • Features
    • Tutorial
      • Prerequisites
      • Installation
      • Configure and Run
      • Swan Provider Tutorial Video
    • FAQ
      • 1. Change the linked Email
      • 2. Check Storage Provider connectivity/stability
      • 3. How to stop accepting "auto-bid" deals?
      • 4. `aria2_download_dir` vs. `aria2_candidate_dirs`
      • 5. How to configure "import deals from Swan Provider" when Boostd is running normally
      • 6. A rejection msg always appears during the deal-importing process
      • 7. How to check if aria2 is running?
      • 8. No response from Swan Platform?
      • 9. Why Storage Provider status shows offline?
      • 10. How to check the Task Status?
      • 11. How to configure the Storage Provider Market?
      • 12. How to set the "ask price"?
      • 13.aria2_download_dir VS. aria2_candidate_dirs
      • 14. How to control the number of deals imported?
  • Swan Client
    • Overview
    • Basic Concepts
    • Tutorial
      • Filecoin Deal Sender
        • Installation
        • Configuration
        • Prerequisites
        • Generate CAR Files
        • Meta-CAR
        • Upload CAR Files to IPFS
        • Create a Task
      • Blockchain RPC Service
        • Deploy RPC Service
        • RPC Command Service
      • Swan Client Tutorial Video
    • FAQ
      • How to prepare data?
  • FS3
    • Overview
    • Setup your FS3
      • Prerequisites
      • Install FS3
      • FS3 Set up Video
    • FS3 User Guide
    • FS3 User Guide (Cloud Version)
  • Lagrange DAO
    • Overview
  • Development Resource
    • Swan Token Contract
      • Acquire Testnet USDC and MATIC tokens
    • Swan API
    • Swan IPFS Storage API
    • Swan IPFS Storage 2.0 API
    • Flink API
    • FS3 API
    • API keys
  • Swan Testnet
    • Swan Jupiter Testnet
      • How to Participate
      • Before You Get Started
      • Network Early Adopter
      • Computing Provider Setup
        • Prerequisites
        • Install the Kubernetes
        • Install and config the Nginx
        • Install the Hardware resource-exporter
        • Install the Redis service
        • Build and config the Computing Provider
        • Install AI Inference Dependency(Optional)
        • Start the Computing Provider
        • CLI of Computing Provider
        • FAQ
      • FAQ
Powered by GitBook
On this page
  • System Design
  • How does Swan IPFS Storage work?
  • Modules
  • How Can I Start Building
  • Prerequisites
  • Installation
  • After Installation
  • Configuration

Was this helpful?

  1. Swan IPFS Storage

Developer Quickstart

PreviousSetup MetaMaskNextSDK

Last updated 20 days ago

Was this helpful?

Swan IPFS Storage is a suite of Ethereum scaling solutions that enables high-throughput, low cost smart contracts while remaining trustworthy secure.

The following documentation describes how to use Swan IPFS Storage, which is currently live on Swan Mainnet. Whether you're a developer that just wants to start building or you're curious into digging deeper into the internals of Swan IPFS Storage and how it works, this site is the right place for you.

System Design

How does Swan IPFS Storage work?

Modules

Token Swap: Token Swap module is in charge of swap the user's token to wrapped token, it can be USDC or other tokens.

  1. Users pay USDC or other tokens, which are called user tokens, when uploading a file.

  2. Swan IPFS Storage uses FIL, which is called wrapped token, to pay when store data to Filecoin network.

  3. User tokens should be changed to wrapped token by this module and this step is called token exchange(swap).

  4. Token exchange(swap) is done through Sushi Swap which is a DEX.

Payment Module:

  1. After a file is uploaded, the money to be paid is estimated based on the

    • the average price of all the swan miners;

    • file size;

    • duration;

  2. In refund step, the overpayment part that is locked will be returned to user wallet

DAO Signature: If DAO detects that the file uploaded has been chained, it will trigger a signature operation

How Can I Start Building

Prerequisites

  • OS: Ubuntu 20.04 LTS

  • Mysql5.5+

Lotus Node

  • Lotus node is used for making car files and sending offline deals.

  • Install lotus node or louts lite node in the same machine as Swan IPFS Storage.

  • Lotus full node is too heavy compared with lotus lite node, so lotus lite node is preferred.

  • Lotus lite node depends on a lotus node, so ensure that a lotus node exists somewhere when using lotus lite node.

Installation

wget https://github.com/filswan/multi-chain-payment/releases/tag/v1.0.1/install.sh
./install.sh

Option2️⃣ Source Code

🔔go 1.16+ is required

git clone https://github.com/filswan/multi-chain-payment.git
cd multi-chain-payment
git checkout <release_branch>
./build_from_source.sh

After Installation

  • Before executing, you should check your configuration in ~/.swan/mcp/config.toml to ensure it is right.

vi ~/.swan/mcp/config.toml
  • Before executing, you should check your enviornment variable in ~/.swan/mcp/.env to ensure it is right.

vi ~/.swan/mcp/.env
  • After set your config and env variable in the related files, you can run multi-chain-payment in ./build directory.

./build/multi-chain-payment

Note

  • Logs are in directory ./logs

  • You can add nohup before ./multi-chain-payment to ignore the HUP (hangup) signal and therefore avoid stop when you log out.

  • You can add >> mcp.log in the command to let all the logs output to mcp.log.

  • You can add & at the end of the command to let the program run in background.

  • Such as:

nohup ./multi-chain-payment-0.2.1-rc1-unix >> mcp.log &   #After installation from Option 1
nohup ./build/multi-chain-payment >> ./build/mcp.log &    #After installation from Option 2

Configuration

You need to modify the config file and input your config params, the configuration items will be introduced below:

config.toml

  • port: Web api port.

  • release: When work in release mode: set this to true, otherwise to false and environment. variable GIN_MODE not to release.

  • swan_platform_fil_wallet: The wallet address used to pay on the Filecoin network.

  • filink_url: Deals data can be searched from here.

[lotus]

[ipfs_server]

  • download_url_prefix: IPFS server url prefix, such as: http://[ip]:[port]. Store car files for downloading by storage provider. Car file url will be [download_url_prefix]/ipfs/[file_hash]

  • upload_url_prefix: IPFS server url for uploading files, such as http://[ip]:[port]

[swan_task]

  • dir_deal: Output directory for saving generated Car files and CSVs.

  • verified_deal: [true/false] Whether deals in this task are going to be sent as verified.

  • fast_retrieval: [true/false] Indicates that data should be available for fast retrieval.

  • start_epoch_hours: start_epoch for deals in hours from current time.

  • expired_days: expected completion days for storage provider sealing data.

  • max_price: Max price willing to pay per GiB/epoch for offline deal.

  • generate_md5: [true/false] Whether to generate MD5 for each car file, note: this is a resource consuming action.

[polygon]

  • rpc_url: your polygon network RPC URL.

  • payment_contract_address: swan payment gateway address on polygon to lock money.

  • sushi_dex_address: sushi address on polygon.

  • usdc_wFil_pool_contract: address to get exchange rate between USDC and wFil from sushi on polygon.

  • dao_contract_address: swan DAO address on polygon, to receive DAO signatures.

  • mcp_payment_receiver_address: Swan IPFS Storage wallet address to receive money from unlock operation.

  • gas_limit: gas limit for transaction.

  • unlock_interval_minute: unlock interval in minutes between 2 unlock operations, in cannot be less than 1.

.env

  • privateKeyOnPolygon: private key of the wallet used to execute contract methods on the polygon network and pay for gas.

If you're looking to discover how Swan IPFS Storage works, the best place to begin is by the section, which gives a high level overview of Swan IPFS Storage's internals. From there, you can jump into more detailed explainers on various components of the system.

Then the estimated amount of money will be locked to the payment contract address, see .

In unlock step, the amount pay to Filecoin network by swan platform FIL wallet, will be transferred to Swan IPFS Storage payment receiver address, see .

Swan Client API: More information can be found .

Data DAO: More information can be found at .

IPFS: More information can be found .

Filecoin Storage: More information can be found .

Option1️⃣

Option2️⃣

Option1️⃣ Prebuilt package: See

client_api_url: URL of lotus client web api, such as: http://[ip]:[port]/rpc/v0, generally the [port] is 1234. See

client_access_token: Access token of lotus client web api. It should have admin access right. You can get it from your lotus node machine using command lotus auth create-token --perm admin. See

Want to learn more? Check out the and . Join the team on .

User Guide
Configuration
Configuration
here
Flink
here
here
Lotus Node
IPFS Client
install a lotus full node
install a lotus lite node
release assets
Lotus API
Obtaining Tokens
open source code
API
Discord