Skip to content

getProviderIdByAddress

getProviderIdByAddress(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/sp-registry/get-provider-id-by-address.ts:70

Get provider ID by address

Returns the provider ID for a given provider address, or null when the address is not registered as a provider (the contract returns 0 in that case; this wrapper normalizes it to null).

Parameter Type Description
client Client<Transport, Chain> The client to use to get the provider ID.
options OptionsType getProviderIdByAddress.OptionsType

Promise<OutputType>

The provider ID, or null when the address is not registered 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 === null) {
  console.log('Provider not found')
} else {
  console.log(`Provider ID: ${providerId}`)
}