getStarknetId
Action for getting a Starknet ID.
Import
import { getStarknetId } from "starkweb/core";
Usage
index.ts
import { getStarknetId } from "starkweb/core";
import { config } from "./config";
const starknetId = await getStarknetId(config, {
address: "0x123...",
});
Parameters
import { type GetStarknetIdParameters } from "starkweb/core";
address
Hex
The address to get the Starknet ID for.
index.ts
import { getStarknetId } from "starkweb/core";
import { config } from "./config";
const starknetId = await getStarknetId(config, {
address: "0x123...",
});
chainId (optional)
Hex | undefined
The chain ID to query. If not provided, uses the current chain.
index.ts
import { getStarknetId } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
const starknetId = await getStarknetId(config, {
address: "0x123...",
chainId: mainnet.chain_id,
});
Return Type
import { type GetStarknetIdReturnType } from "starkweb/core";
string
The Starknet ID associated with the address.
Example
example.ts
import { getStarknetId } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
// Get Starknet ID on current chain
const starknetId = await getStarknetId(config, {
address: "0x123...",
});
console.log("Starknet ID:", starknetId);
// Get Starknet ID on specific chain
const mainnetStarknetId = await getStarknetId(config, {
address: "0x123...",
chainId: mainnet.chain_id,
});
Error
import { type GetStarknetIdErrorType } from "starkweb/core";
TanStack Query
import {
type GetStarknetIdData,
type GetStarknetIdOptions,
type GetStarknetIdQueryFnData,
type GetStarknetIdQueryKey,
getStarknetIdQueryKey,
getStarknetIdQueryOptions,
} from "starkweb/query";