Skip to content

getConnectorClient

Action for getting a Starknet connector's client instance.

Import

import { getConnectorClient } from "starkweb/core";

Usage

index.ts
import { getConnectorClient } from "starkweb/core";
import { config } from "./config";
 
const client = await getConnectorClient(config); 

Parameters

import { type GetConnectorClientParameters } from "starkweb/core";

chainId (optional)

Hex | undefined

The chain ID to get the client for.

index.ts
import { getConnectorClient } from "starkweb/core";
import { mainnet } from "starkweb/chains"; 
import { config } from "./config";
 
const client = await getConnectorClient(config, {
  chainId: mainnet.chain_id, 
});

connector (optional)

Connector | undefined

The specific connector to get the client for. If not provided, uses the current connector.

index.ts
import { getConnectorClient } from "starkweb/core";
import { injected } from "starkweb/connectors"; 
import { config } from "./config";
 
const connector = injected();
const client = await getConnectorClient(config, {
  connector, 
});

account (optional)

Address | Account | undefined

The account to get the client for. If not provided, uses the first account.

index.ts
import { getConnectorClient } from "starkweb/core";
import { config } from "./config";
 
const client = await getConnectorClient(config, {
  account: "0x1234...", 
});

Return Type

import { type GetConnectorClientReturnType } from "starkweb/core";

Client<Transport, Chain, Account>

A configured client instance for interacting with Starknet.

Example

example.ts
import { getConnectorClient } from "starkweb/core";
import { injected } from "starkweb/connectors"; 
import { mainnet } from "starkweb/chains"; 
import { config } from "./config";
 
// Get client with specific chain and connector
const connector = injected();
const client = await getConnectorClient(config, {
  chainId: mainnet.chain_id, 
  connector, 
});
 
// Use client to interact with Starknet
const balance = await client.getBalance({
  address: "0x1234...",
});

Error

import { type GetConnectorClientErrorType } from "starkweb/core";

TanStack Query

import {
  type GetConnectorClientData,
  type GetConnectorClientOptions,
  type GetConnectorClientQueryFnData,
  type GetConnectorClientQueryKey,
  getConnectorClientQueryKey,
  getConnectorClientQueryOptions,
} from "starkweb/query";