I am trying to implement smoldot @substrate-connect light client to my DApp using chain specs of a substrate-based parachain. Substrate connect extension is able to discover the parachain as it shows the current block and keeps on syncing but I do not get apiPromise needed to make rpc request. The bootnodes I am using in my chainspecs is publically accessible as I can make RPC calls using curl but the issue is I cannot get apiPromise as suggested by substrate_connect npm package. Can anybody point me toward possible issues...
import chainSpecs from '../parachain.json';
import { ScProvider } from '@polkadot/rpc-provider/substrate-connect';
import { ApiPromise } from '@polkadot/api';
import { WellKnownChain } from '@substrate/connect';
const getPolkadotApi = async () => {
try {
const relayProvider = new ScProvider(JSON.stringify(relayChainSpecs));
await relayProvider.connect();
const stringifyChainSpec = JSON.stringify(chainSpecs);
const provider = new ScProvider(stringifyChainSpec, relayProvider);
console.log('waiting for connection');
await provider.connect();
console.log('check, provider);
const _api = await ApiPromise.create({ provider });
console.log(`Connected to ${POLKADOT_RPC_URL},API is ${_api}`);
return _api;
} catch (err) {
console.log('this is the error', err);
return null;
}
};
output:
waiting for connection
polkadot.js:42 checkkk ScProvider {...}