Skip to content

polkadot-developers/polkadot-api-ts-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers


Polkadot API Typescript Boilerplate

Quickly get started with experimenting with the Polkadot API. Includes hot-reloading and a clean Typescript environment to work with.

Getting Started

Getting started should be simple - simply npm install, and you're off to the races.

Prerequisites

Be sure npm and npx is up to date and working:

npm install npm@latest -g

Installation

npm install

Usage

You can start a hot reloading server with tsc-watch, which will automatically apply your code changes live:

npm run start

Alternatively, you can also build the project and run the files manually inside dist/:

npm run build

Adding a custom chain

If you want to add a custom chain, such as a local one, you need to first get the metadata for your chain. You can replace ws://localhost:9944 with your node's appropriate URL:

npx papi add custom --wsUrl ws://localhost:9944

Then, make sure you are using the WebSocket client (wsClient or withWebSocket(url)) and your custom metadata:

// ...
const wsClient = await withWebSocket("ws://localhost:9944");
const dotApi = wsClient.getTypedApi(custom);

// Then, you can make calls like this...
const last_runtime_upgrade = await dotApi.query.System.LastRuntimeUpgrade.getValue();
console.log(last_runtime_upgrade)
// ...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published