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.

Can't connect successfully to Polkadot node

See original GitHub issue

Please let me know if this is rather an issue with Polkadot as opposed to polkadot.js and if I should report this somewhere else.

I’ve installed polkadot from its git repository and spinned up a node via

$ polkadot --dev

Next I wanted to try to connect to it via polkadot.js, so I took the “Simple Connect” example and ran it against my local node:

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

async function main() {
  const provider = new WsProvider('ws://127.0.0.1:9944');
  const api = await ApiPromise.create(provider);

  const [chain, nodeName, nodeVersion] = await Promise.all([
    api.rpc.system.chain(),
    api.rpc.system.name(),
    api.rpc.system.version()
  ]);

  console.log(`Connected to: ${chain} using ${nodeName} v${nodeVersion}`);
}

main().catch(console.error).finally(() => process.exit());

^ This is polkadot/api v^0.8.1 and polkadot version latest HEAD from master which at the time of creating this issue was 12cb9cb5.

Running this script gives me the following error:

2019-07-16 15:23:34        RPC-CORE: getMetadata (block: Hash): Metadata:: U8a: failed on 'MagicNumber':: U8a: failed on 'MetadataEnum':: Unable to create Enum via index 6, in
MetadataV0, MetadataV1, MetadataV2, MetadataV3, MetadataV4, MetadataV5
2019-07-16 15:23:34   API/DECORATOR: Error: FATAL: Unable to initialize the API: getMetadata (block: Hash): Metadata:: U8a: failed on 'MagicNumber':: U8a: failed on 'MetadataEnum':: Unable to create Enum via index 6, in MetadataV0, MetadataV1, MetadataV2, MetadataV3, MetadataV4, MetadataV5                                                             
    at EventEmitter._rpcBase._provider.on (/Users/pascalprecht/projects/embark/polkadot-playground/node_modules/@polkadot/api/Base.js:433:23)                                  
    at process._tickCallback (internal/process/next_tick.js:68:7)

Any idea what I need to do?

Also, I’ve noticed that simply installing @polkadot/api won’t do it as it needs bs58 to run as well. I needed to install it explicitly, maybe it should come as a (peer)dependency of polkadot/api.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
0x-r4bbitcommented, Jul 16, 2019

This has worked well, thank you!

0reactions
polkadot-js-botcommented, Jun 5, 2021

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

How to fix connection issues on polkadot.js
This usually fixes things, in case one node has connection issues. Simply select the other node and then click the "Switch" button on...
Read more >
Setting Up a Polkadot Node (the easy way) | by Alberto Cevallos
This command sets up your node but won't sync with the rest of the network. Meaning, it'll appear in Telemetry but won't sync...
Read more >
Create an Account on Polkadot.js Apps - Moonbeam Docs
First, you need to connect it to the Moonbase Alpha TestNet by clicking the logo in the top left corner, then scroll down...
Read more >
Authorize specific nodes | Substrate_ Docs
Open the Polkadot/Substrate Portal in a browser. Click Developer and select Extrinsics. Select nodeAuthorization and select addConnections(node, connections).
Read more >
How to Stake DOT (Polkadot) - Blockdaemon
It's easy to participate in the Polkadot network with Blockdaemon. ... Any less than this, and you won't be able to stake. ......
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