Crust Wiki

Crust Wiki

  • 文档
  • Shadow
  • 贡献
  • Languages icon中文
    • English
    • Help Translate
Translate

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/[email protected] @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.filesV2('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.FileInfoV2;

// Use FileInfo as `interface`
  • Types

    • DSM Types: FileInfoV2, 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.

  • 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