2
votes

I've got a Substrate node running locally on my PC, following this tutorial. https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/interact. It can be viewed on two ports:

  Local:            http://localhost:8000/substrate-front-end-template
  On Your Network:  http://192.168.56.1:8000/substrate-front-end-template

So I don't think connectivity is the issue.

Anyway, I bound the @polkadot/api to my node via the command:

yarn add @polkadot/api.

I'm now getting an error, in the browser, whenever I run my node:

Error Connecting to Substrate
Error: FATAL: Unable to initialize the API: createType(StorageKey):: Derived TypedArray constructor created an array which was too small

Can anyone help?

1
Are you running an unmodified version of the Node Template, or did you make changes to it? If you made changes to the types, you probably need to register these when you initiate the API connection: polkadot.js.org/docs/api/start/types.extend - Dan Forbes
@DanForbes Other than putting 'yarn add @polkadot/api' in the substrate-front-end-template, I have made no changes to the types. Does running 'yarn add @polkadot/api' change types? - Sarah Kay
@DanForbes I also can't find documentation about where to run JavaScript files to retrieve information about the node (via the API). Do I run them as snippets in the browser? - Sarah Kay
You should not need to add the API to the front-end template, it already has it github.com/substrate-developer-hub/substrate-front-end-template/… You can run the scripts in Node as well as I'm doing here github.com/danforbes/polkadot-js-scripts - Dan Forbes
You can run the scripts from anywhere that you can establish a connection to a node, which may be running on your local machine or on some remote machine. To connect to the node, you do not require a path, you configure the client library with the URL of the RPC server of the node you want to connect to. For instance, the Front-End Template is configured to connect to the local node, but you can change this github.com/substrate-developer-hub/substrate-front-end-template/… - Dan Forbes

1 Answers

0
votes

Upgrading to the latest Substrate Sidecar API resolved these issues for me.