Javascript Custom RPC

MRC Custom RPC and Types for Polkadot JS API
An easy way to get all the custom rpc and types config to be able to easily use MRC with the Polkadot JS API library.
Getting Started
npm install @polkadot/api
(Polkadot API Library)
npm install @dsnp/mrc-rpc
Usage
For details on use, see the Polkadot API library documentation.
import { ApiPromise } from '@polkadot/api';
import { rpc, types } from "@dsnp/mrc-rpc";
const mrcAPI = await ApiPromise.create({
rpc,
types,
});
const { ApiPromise } = require('@polkadot/api');
const { rpc, types } = require("@dsnp/mrc-rpc");
const mrcAPI = await ApiPromise.create({
rpc,
types,
});
Contributing
See CONTRIBUTING.md for more information.
Helpful Notes
Option
Optional responses are not mapped to null
and instead return an object with a few properties.
For more details see the code for the Option class.
const optionalExample = await api.rpc.msa.getMsaId(account);
if (!optionalExample.isEmpty) {
return optionalExample.value;
}
return null;
Vec
Vector responses are not mapped directly to a JavaScript Array.
Instead they are mapped to the Vec class which does extend Array.
Thus, you can still use map
, forEach
, etc... with responses or access the values directing via .values()
.
License
Distributed under the Apache 2.0 License. See LICENSE
for more information.