5

Let's say I want to build a dapp, and I know which pallets it would require. How do I find out which of the current parachains (both Polkadot and Kusama) contain these pallets?

I know https://(kusama|polkadot|etc).subscan.io/runtime exists, but is there a way to do this programmatically?

3 Answers 3

4

If you want to do this on the front end, this solution is a bit hacky but you could use Polkadot{.js} API to check if the storage exists for that particular pallet (assuming that all pallets your dApp uses rely on pallet storage).

For example to check the if the staking pallet exists in Polkadot and Rococo:

import { ApiPromise, WsProvider } from '@polkadot/api';

export const getStorage = async () => {

    // Polkadot
    const wsPolkadotProvider = new WsProvider('wss://rpc.polkadot.io');
    const polkadotApi = await ApiPromise.create({ provider: wsPolkadotProvider });
    console.log(await polkadotApi.query.staking)

    // Rococo
    const wsRococoProvider = new WsProvider('wss://rococo-rpc.polkadot.io');
    const rococoApi = await ApiPromise.create({ provider: wsRococoProvider });
    console.log(await rococoApi.query.staking)
}

Running this script we see that Polkadot returns methods for staking and Rococo returns undefined because Rococo does not use the staking pallet:

Output:

{
  palletVersion: [Getter],
  historyDepth: [Getter],
  validatorCount: [Getter],
  minimumValidatorCount: [Getter],
  invulnerables: [Getter],
  bonded: [Getter],
  minNominatorBond: [Getter],
  minValidatorBond: [Getter],
  minCommission: [Getter],
....
undefined
4

Great question. If the blockchains you want to interrogate are online then you can get a list of pallets used from the command line using subwasm.

subwasm meta wss://rpc.polkadot.io:433

- 00: System
 - 01: Scheduler
 - 02: Babe
 - 03: Timestamp
 - 04: Indices
 - 05: Balances
 - 06: Authorship
...snip...
 - 71: Slots
 - 72: Auctions
 - 73: Crowdloan

https://github.com/chevdor/subwasm

Personally I would like to see a way of grepping all the runtime lib.rs across all the parachains and solo chains that are open source. I think that would be enlightening.

3

Take a look at the runtime for the parachains in question. You could clone their repos and search the runtime lib.rs for pallet_.* entries.

From the moonbeam runtime:

use pallet_balances::NegativeImbalance;
use pallet_ethereum::Call::transact;
use pallet_ethereum::Transaction as EthereumTransaction;
#[cfg(feature = "std")]
pub use pallet_evm::GenesisAccount;
use pallet_evm::{
    Account as EVMAccount, EnsureAddressNever, EnsureAddressRoot, FeeCalculator, GasWeightMapping,
    Runner,
};
use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};

From the kusama runtime

use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_mmr_primitives as mmr;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};

Here is a quick bash script for doing this:

$ grep -Po '(pallet_[a-z_]*)' runtime/src/lib.rs | sort | uniq 
pallet_aura
pallet_balances
pallet_contracts
pallet_contracts_primitives
pallet_contracts_rpc_runtime_api
pallet_grandpa
pallet_randomness_collective_flip
pallet_sudo
pallet_timestamp
pallet_transaction_payment
pallet_transaction_payment_rpc_runtime_api

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.