crustio / crust.js

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

license npm

crust.js

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

Getting Started

More documentation and examples on Crust Wiki

  1. Install dependencies
yarn add @polkadot/api @crustnetwork/type-definitions
  1. Create API instance
import {ApiPromise, WsProvider} from '@polkadot/api';
import {typesBundleForPolkadot} from '@crustnetwork/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());

Crust Types

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

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

// Use FileInfo as `interface`

Contribution

Please send a PR(Pull Request) to contribute this repo and read the following rules:

  1. No --force pushes or modifying the master branch history in any way. If you need to rebase, ensure you do it in your own repo.
  2. Non-main branches, prefixed with a short name moniker (e.g. zik/my-feature) must be used for ongoing work.
  3. All modifications must be made in pull-request to solicit feedback from other contributors.
  4. A pull-request must not be merged until CI has finished successfully.
  5. Contributors should adhere to the Google Typescript Style Guide.

About

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

License:Apache License 2.0


Languages

Language:TypeScript 84.1%Language:Go 13.6%Language:JavaScript 1.5%Language:Dockerfile 0.8%