Skip to content

Can't connect successfully to Polkadot node #1137

@0x-r4bbit

Description

@0x-r4bbit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions