How to include custom RPC in polkadotjs (+types)
See original GitHub issueWhen 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:
- Created a year ago
- Reactions:1
- Comments:13 (12 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Have it on the list of TODOs, have not gotten there to look.
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.