This library provides additional typing information for users to access Crust Network by using polkadot.js
More documentation and examples on Crust Wiki
- Install dependencies
yarn add @polkadot/api @crustnetwork/type-definitions
- 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();
- Interact with chain
// Query file info
const fileInfo = await api.query.market.files('QmRaknS23vXEcdJezkrVC5WrApQNUkUDdTpbRdvh5fuJHc');
console.log(fileInfo.toHuman());
- Use crust types
import {crustTypes} from '@crustnetwork/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
, ...
- DSM Types:
-
Packages
- type-definitions: Polkadot.js type definations for Crust Network
- crust-pin: Decentralized pin on Crust Network
Please send a PR(Pull Request) to contribute this repo and read the following rules:
- 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. - Non-main branches, prefixed with a short name moniker (e.g. zik/my-feature) must be used for ongoing work.
- All modifications must be made in pull-request to solicit feedback from other contributors.
- A pull-request must not be merged until CI has finished successfully.
- Contributors should adhere to the Google Typescript Style Guide.