getProviderIdByAddress
getProviderIdByAddress(
client,options):Promise<bigint>
Defined in: packages/synapse-core/src/sp-registry/get-provider-id-by-address.ts:68
Get provider ID by address
Returns the provider ID for a given provider address. Returns 0 if the address is not registered as a provider.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain> | The client to use to get the provider ID. |
options | OptionsType | getProviderIdByAddress.OptionsType |
Returns
Section titled “Returns”Promise<bigint>
The provider ID (0 if not found) getProviderIdByAddress.OutputType
Throws
Section titled “Throws”Errors getProviderIdByAddress.ErrorType
Example
Section titled “Example”import { getProviderIdByAddress } from '@filoz/synapse-core/sp-registry'import { createPublicClient, http } from 'viem'import { calibration } from '@filoz/synapse-core/chains'
const client = createPublicClient({ chain: calibration, transport: http(),})
const providerId = await getProviderIdByAddress(client, { providerAddress: '0x1234567890123456789012345678901234567890',})
if (providerId === 0n) { console.log('Provider not found')} else { console.log(`Provider ID: ${providerId}`)}