@starknet-react/core
Version:
Starknet React is a collection of React hooks for Starknet.
15 lines (13 loc) • 460 B
text/typescript
import { jsonRpcProvider } from "./jsonrpc";
/** Configure the provider to use the public RPC endpoint. */
export function publicProvider() {
return jsonRpcProvider({
rpc: (chain) => {
// Pick random node from the list of public nodes.
const rpcs = chain.rpcUrls.public.http;
const nodeUrl = rpcs[Math.floor(Math.random() * rpcs.length)];
if (!nodeUrl) return null;
return { nodeUrl, specVersion: "0.8.1" };
},
});
}