question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to include custom RPC in polkadotjs (+types)

See original GitHub issue

When generating the api-augment with typegen, the additional RPC methods are not included. Additionally those rpc_method are not recognized when polkadotjs connect to the network and load the types.

API/INIT: RPC methods not decorated: eth_feeHistory, eth_maxPriorityFeePerGas, moon_isBlockFinalized, moon_isTxFinalized

Ex: using npm install @moonbeam-network/api-augment@0.1605.3

import "@moonbeam-network/api-augment";
import { ApiPromise, WsProvider } from "@polkadot/api";

const main = async () => {
  const api = await ApiPromise.create({
    provider: new WsProvider("wss://wss.api.moonbase.moonbeam.network"),
  });
  await api.isReady;

  const blockHash = `0x0bbeb2c7b5e7c3e960efd54029404fa2ec4288ff1e1ae6d2b149793a7b0a0226`;
  console.log(`${blockHash} finalized?: ${api.rpc.moon.isBlockFinalized(blockHash)}`);
};

main();

This will fail to compile (because of missing moon) and fail to execute because moon is not decorated in the api object.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jacogrcommented, Jun 20, 2022

Have it on the list of TODOs, have not gotten there to look.

0reactions
polkadot-js-botcommented, Jul 7, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom RPC - polkadot{.js}
Custom RPC. In the previous section we looked at how to override the types the node uses and how to define extra custom...
Read more >
Node Interaction - Polkadot Wiki
Polkadot -JS RPC is a JavaScript library for interacting with the Substrate RPC API endpoint, distributed as @polkadot/api Node.js package.
Read more >
PolkadotJS how to properly setup api for custom RPC invocation
In my frontend I've added the following RPC config to the api creation: const api = await ApiPromise.create({ provider, rpc: { iris: { ......
Read more >
How to use the Polkadot.js API - Moonbeam Docs
Substrate and Custom JSON-RPC Endpoints¶ · Interface - api.rpc.chain.getBlock · JSON-RPC - chain_getBlock · Returns - The header and body of a block...
Read more >
@polkadot/rpc-provider | Yarn - Package Manager
Contributed: Improve rpc-provider README (Thanks to https://github.com/josepot); Add handling for Vec<[<Type>;<length>]> in typegen (Thanks to https://github.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found