1

I am using Substrate Connect in the browser following the docs for a custom chain spec. When I try to create a new ScProvider like the documentation suggests i get an error that I am missing a variable in the constructor.

TS2554: Expected 2-3 arguments, but got 1.
    41 | // Create the provider for the custom chain
    42 |     const customSpec = JSON.stringify(jsonCustomSpec);
  > 43 |     const provider = new ScProvider(customSpec);

In the substrate lib the constructor code is asking for SubstrateConnect. Any ideas on this?

1 Answer 1

3

You need at least the SubstrateConnect instance (And the relay chain in case of a parachain).

See the example to connect to Statemint:

import { ScProvider} from "@polkadot/rpc-provider";
import * as Sc from "@substrate/connect";
import { ApiPromise } from "@polkadot/api";
import jsonParachainSpec from "./statemint.json";

 const relayProvider = new ScProvider(Sc, Sc.WellKnownChain.polkadot);
 const parachainSpec = JSON.stringify(jsonParachainSpec);
 const provider = new ScProvider(Sc, parachainSpec, relayProvider);
      
 await provider.connect();

1
  • this did it. thank you. import * as Sc from "@substrate/connect"; then use the Sc in new ScProvider(Sc, spec); Feb 2 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.