Crust Wiki

Crust Wiki

  • 文档
  • 主网
  • 贡献
  • Languages icon中文
    • English
    • Help Translate

›构建

概览

  • 开始
  • Shadow Bridge
  • CSM 认领

学习

  • 即将到来

构建

  • 即将到来

节点

  • 即将到来

存储

  • 即将到来

Maxwell

    概览

    • 开始
    • 预览网 Maxwell
    • Crust Grants
    • Ethereum Bridge
    • CRU 转回
    • CRU18 认领
    • CSM 转回
    • Crust 钱包
    • 术语表
    • 社区
    • 贡献

    学习

    • 账户
    • Crust 通证
    • 新增绑定
    • sWorker
    • 担保人
    • 验证人
    • 存储商户
    • GPoS
    • 去中心化存储市场
    • BitSwap
    • 民主指南

    构建

    • 开始
    • Hello Crust
    • Crust Rocky Network
    • 代码示例:使用Crust
    • Crust SDK
    • 总览
    • 部署和运行网站
    • 内容存储与分发
    • NFT数据存储
    • Crust Storage Manager
    • Crust Node

    节点

    • 节点概要
    • 节点硬件指南
    • Owner 节点
    • Member 节点
    • Isolation 节点
    • 验证人指南
    • 担保人指南
    • 参数表
    • Q&A

    存储

    • 概览
    • 存储用户指南
    • 存储商户指南
    • 存储订单清算指南
    • 使用Crust Apps 存储的问题
    • Crust 存储浏览器
    • Q&A
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/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

PolkadotJS API

The PolkadotJS API document can be found here.

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.

Contributes on Crust API Specifications

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

← 代码示例:使用Crust总览 →
  • Getting Started
  • Crust Types
  • Additional Resources
  • API Specifications
    • PolkadotJS API
    • Crust 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