🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@polkadot/api-derive

Package Overview
Dependencies
Maintainers
2
Versions
2813
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot/api-derive

Common functions used across Polkadot, derived from RPC calls and storage queries.

16.2.2
latest
Source
npm
Version published
Weekly downloads
233K
20.61%
Maintainers
2
Weekly downloads
 
Created

What is @polkadot/api-derive?

@polkadot/api-derive is a collection of derived methods for interacting with the Polkadot and Substrate blockchains. It provides higher-level abstractions over the basic API calls, making it easier to work with complex blockchain data.

What are @polkadot/api-derive's main functionalities?

Account Balances

This feature allows you to retrieve all balance-related information for a specific account, including free balance, reserved balance, and more. The code sample demonstrates how to use the `all` method from the balances derive module to fetch this data.

const { ApiPromise, WsProvider } = require('@polkadot/api');
const { all } = require('@polkadot/api-derive/balances');

async function main() {
  const provider = new WsProvider('wss://rpc.polkadot.io');
  const api = await ApiPromise.create({ provider });
  const account = '5F3sa2TJAWMqDhXG6jhV4N8ko9rLh5N1zWQ4i5Q3r1uXkP4q';
  const balances = await all(api, account);
  console.log(balances);
}

main().catch(console.error);

Staking Information

This feature provides detailed staking information for a specific account, such as the staking ledger, rewards, and nominations. The code sample shows how to use the `info` method from the staking derive module to obtain this information.

const { ApiPromise, WsProvider } = require('@polkadot/api');
const { staking } = require('@polkadot/api-derive');

async function main() {
  const provider = new WsProvider('wss://rpc.polkadot.io');
  const api = await ApiPromise.create({ provider });
  const stakingInfo = await staking.info(api, '5F3sa2TJAWMqDhXG6jhV4N8ko9rLh5N1zWQ4i5Q3r1uXkP4q');
  console.log(stakingInfo);
}

main().catch(console.error);

Chain Information

This feature allows you to access chain-related information, such as the best block number. The code sample demonstrates how to use the `bestNumber` method from the chain derive module to get the current best block number.

const { ApiPromise, WsProvider } = require('@polkadot/api');
const { chain } = require('@polkadot/api-derive');

async function main() {
  const provider = new WsProvider('wss://rpc.polkadot.io');
  const api = await ApiPromise.create({ provider });
  const bestNumber = await chain.bestNumber(api);
  console.log(`Best block number: ${bestNumber}`);
}

main().catch(console.error);

Other packages similar to @polkadot/api-derive

FAQs

Package last updated on 17 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts