This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the documentation portal.
If you are an existing user, please be sure to track the CHANGELOG and UPGRADING guides when changing versions.
Looking for tutorials to get started? Look at examples for guides on how to use the API to make queries and submit transactions.
This fork includes a modified typegen utility that can generate an OpenRPC document.
Create a folder for the output file(s):
mkdir output_directory
Install the project:
yarn install
Start up a node (if it isn't already running) and use it's IP address below:
yarn polkadot-types-from-chain --openrpc --endpoint ws://127.0.0.1:9944 --output FOLDER_THAT_MUST_ALREADY_EXIST
To add support for additional complex types, you must:
- Add a
$ref
mapping for each to the code inopenrpc.ts
:
['AccountId32', { $ref: '#/components/schemas/AccountId32' }],
- Add an entry to the handlebars template
openrpc.hbs
for the new complex type:
"components": {
"schemas": {
"AccountId32": {
"title": "AccountId32",
"description": "A 32-byte encoded account identifier used to identify accounts on the Polkadot network",
"type": "string",
"pattern": "^[a-fA-F0-9]{64}$"
}
}
}
See also: