Skip to content

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.

ParameterTypeDescription
clientClient<Transport, Chain>The client to use to get the provider ID.
optionsOptionsTypegetProviderIdByAddress.OptionsType

Promise<bigint>

The provider ID (0 if not found) getProviderIdByAddress.OutputType

Errors getProviderIdByAddress.ErrorType

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}`)
}