Crust Wiki

Crust Wiki

  • Docs
  • Mainnet
  • Contribute
  • Languages iconEnglish
    • 中文
    • Help Translate

›Build

General

  • Getting Started
  • Shadow Bridge
  • CSM Claim

Learn

  • Comming soon.

Build

  • Comming soon.

Node

  • Comming soon.

Storage

  • Comming soon.

Maxwell

    General

    • Getting Started
    • Preview Network Maxwell
    • Crust Grants
    • Ethereum Bridge
    • CRU Claim Back
    • CRU18 Claim
    • CSM Claim Back
    • Crust Wallet
    • Glossary
    • Community
    • Contributing

    Learn

    • Account
    • Crust Tokens
    • New Bond
    • sWorker
    • Guarantor
    • Validator
    • Storage Merchant
    • GPoS
    • DSM
    • BitSwap
    • Democracy Guide

    Build

    • Getting Started
    • Hello Crust
    • Crust Rocky Network
    • Code Sample to Use Crust
    • Crust SDK
    • Overview
    • Website Hosting
    • Content Storage & Delivery
    • NFT Data Storage
    • Crust Storage Manager
    • Crust Node

    Node

    • Node Overview
    • Node Hardware Spec
    • Owner Node
    • Member Node
    • Isolation Node
    • Validator Guidance
    • Guarantor Guidance
    • Parameters
    • Q&A

    Storage

    • Overview
    • User Guidance
    • Merchant Guidance
    • Order Settlement
    • Apps Strorage Issue
    • Crust Storage Explorer
    • Q&A
Edit

Crust SDK

Crust provides PolkadotJS based SDK to access Crust Network functionalities. It is implemented as crust.js library to provide additional type definitions.

crust.js

This library provides additional typing information for users to access Crust Network by using polkadot.js

Getting Started

  1. Install dependencies
yarn add @polkadot/api @crustio/type-definitions
  1. Create API instance
import {ApiPromise, WsProvider} from '@polkadot/api';
import {typesBundleForPolkadot} from '@crustio/type-definitions';

async function main() {
    const api = new ApiPromise({
      provider: new WsProvider('wss://api.crust.network'),
      typesBundle: typesBundleForPolkadot,
    });
    await api.isReady;

    // Use api
}

main();
  1. Interact with chain
// Query file info
const fileInfo = await api.query.market.files('QmRaknS23vXEcdJezkrVC5WrApQNUkUDdTpbRdvh5fuJHc');
console.log(fileInfo.toHuman());

E2E code sample can be found here.

Crust Types

  • Use crust types
import {crustTypes} from '@crustio/type-definitions';

// Define FileInfo
export type FileInfo = typeof crustTypes.market.types.FileInfo;

// Use FileInfo as `interface`
  • Types

    • DSM Types: FileInfo, MerchantLedger, Replica, ...
    • MPoW Types: Identity, WorkReport, ...
    • GPoS Types: Guarantee, ...

Additional Resources

  • @polkadot/api The polkadot api library provides a Promise-style interface for performing related operations on substrate-based chains including Crust chain
  • ipfs-core ipfs library contains all the functions of ipfs

API Specifications

Crust API

Please visit Crust Docs to check all Crust API. You can check the Constants to get all constants stored on chain. You can learn how the chain state organazied on Storage page and all supported extrinsices on Extrinsics. You can check the Events and Errors as well if neccessary.

PolkadotJS API

The PolkadotJS API document can be found here.

Contributes on Crust API Specifications

You are welcome to contribute on Crust API specifications to provide more integrated and user-friendly documents.

← Code Sample to Use CrustOverview →
  • Getting Started
  • Crust Types
  • Additional Resources
  • API Specifications
    • Crust API
    • PolkadotJS API
    • Contributes on Crust API Specifications
Docs
Getting StartedCRU ClaimsWebsite Hosting with CrustNFT Data Storage with Crust
Community
DiscordTwitterTelegram
More
CooperationGitHub
Copyright © 2025 Crust Network