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
  • Upload File
  • Pay for File Storage
  • Create NFT Collection
  • List NFT Collections
  • Mint Assets as NFTs

Was this helpful?

  1. Swan IPFS Storage
  2. Developer Quickstart
  3. SDK
  4. python MCS SDK

Onchain Storage

Guide to multichain.storage's onchain storage

Onchain storage allows users to upload files to the IPFS server and backup into filecoin network.

Upload File

upload(file_path)

Upload your file to IPFS and Filecoin network

from swan_mcs import APIClient, OnchainAPI
mcs_api = APIClient("<API_KEY>", "<ACCESS_TOKEN>", "<CHAIN_NAME>")
onchain_client = OnchainAPI(mcs_api, "<PRIVATE_KEY>", "<RPC_ENDPOINT>")

onchain_client.upload("<FILE_PATH>")

Parameters

  • file_path: The file path to upload

Return

{
    "file_size": 1804,
    "ipfs_url": "https://ipfs.multichain.storage/ipfs/Qm...",
    "payload_cid": "Qm...",
    "source_file_upload_id": 151309,
    "status": "Pending",
    "w_cid": "a06...kYt"
}

Pay for File Storage

pay(source_file_upload_id, file_size)

Pay for your file (in USDC) to be stored on the Filecoin network.

from swan_mcs import APIClient, OnchainAPI
mcs_api = APIClient("<API_KEY>", "<ACCESS_TOKEN>", "<CHAIN_NAME>")
onchain_client = OnchainAPI(mcs_api, "<PRIVATE_KEY>", "<RPC_ENDPOINT>")

onchain_client.pay("<SOURCE_FILE_UPLOAD_ID>", "<FILE_SIZE>")

Parameters

  • source_file_upload_id: The unique upload id of the file

  • file_size: the file size

Return

Returns the payment transaction hash

"0x..."

Create NFT Collection

create_collection(collection_metadata)

Create your own NFT collection

from swan_mcs import APIClient, OnchainAPI
mcs_api = APIClient("<API_KEY>", "<ACCESS_TOKEN>", "<CHAIN_NAME>")
onchain_client = OnchainAPI(mcs_api, "<PRIVATE_KEY>", "<RPC_ENDPOINT>")

COLLECTION_DATA = {
    "name": '',
    "description": '',
    "image": '',
    "external_link": '',
    "seller_fee_basis_points": '',
    "fee_recipient": '' 
}

onchain_client.pay(COLLECTION_DATA)

Parameters

  • collection_metadata: A dictionary containing the metadata information of the collection

Return

Returns the created collection transaction hash and collection info

{
    "name": '',
    "description": '',
    "image": '',
    "external_link": '',
    "seller_fee_basis_points": '',
    "fee_recipient": '' 
    "tx_hash": "0xA...",
}

List NFT Collections

get_collections()

List all of your NFT Collections created on MCS

from swan_mcs import APIClient, OnchainAPI
mcs_api = APIClient("<API_KEY>", "<ACCESS_TOKEN>", "<CHAIN_NAME>")
onchain_client = OnchainAPI(mcs_api, "<PRIVATE_KEY>", "<RPC_ENDPOINT>")

for i in onchain_client.get_collections():
    print(i.to_json())

Return

Returns a list of Collection Objects

{
    "address": "0x511...78e",
    "create_at": 1675178532,
    "description": null,
    "external_link": null,
    "id": 7,
    "image_url": "https://ipfs.multichain.storage/ipfs/Qm...",
    "is_default": true,
    "name": "Collection Name",
    "seller_fee": null,
    "tx_hash": null,
    "update_at": 1675178532,
    "wallet_id": null,
    "wallet_id_recipient": null,
    "wallet_recipient": ""
}
...

Mint Assets as NFTs

mint(source_file_upload_id, nft_object, collection_address='', quantity=1)

from swan_mcs import APIClient, OnchainAPI
mcs_api = APIClient("<API_KEY>", "<ACCESS_TOKEN>", "<CHAIN_NAME>")
onchain_client = OnchainAPI(mcs_api, "<PRIVATE_KEY>", "<RPC_ENDPOINT>")

SOURCE_FILE_UPLOAD_ID = ''
NFT_OBJECT = {
    "name": "",
    "description": "",
    "image": ""
}
COLLECTION_ADDRESS = ''

onchain_client.pay(SOURCE_FILE_UPLOAD_ID, NFT_OBJECT, COLLECTION_ADDRESS)

Parameters

  • source_file_upload_id: The unique id of the file

  • nft_object: a python dictionary containing the nft information

  • collection_address: the collection address to mint to

  • quantity: the quantity of tokens to mint (ERC-1155)

Return

{
    "hash": "0xA...",
    "tx_hash": "0xA...",
    "id": "##",
    "token_id": "##"
}
PreviousBucket StorageNextSDK Python Installation Tutorial Video

Last updated 23 days ago

Was this helpful?