0

For example, the utility pallet has a constant called batched_calls_limit. How do I access this from polkadot-js?

        {
          "name": "Utility",
          "storage": null,
          "calls": {
            "type": 125
          },
          "events": {
            "type": 29
          },
          "constants": [
            {
              "name": "batched_calls_limit",
              "type": 4,
              "value": "0xaa2a0000",
              "docs": [
                " The limit on the number of batched calls."
              ]
            }
          ],
          "errors": {
            "type": 414
          },
          "index": 1
        },

The docs cryptically state that its available in constant metadata.

       * - `calls`: The calls to be dispatched from the same origin. The number of call must not
       * exceed the constant: `batched_calls_limit` (available in constant metadata).

1 Answer 1

1

You can access the Utility constant(s) like this:

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

export const getUtilityConstants = async () => {

    const wsProvider = new WsProvider('wss://rpc.polkadot.io');
    const api = await ApiPromise.create({ provider: wsProvider });

    const utilityConstants = await api.consts.utility;
    console.dir(utilityConstants, { depth: 5 });
    console.log(utilityConstants.batchedCallsLimit.toHuman());
}

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.