Skip to main content
@tevm/voltaire
@tevm/voltaire / provider / provider/eip6963

provider/eip6963

EIP-6963: Multi Injected Provider Discovery Enables dapps to discover multiple wallet providers and wallets to announce themselves.

Dapp Usage (Consumer)

import * as EIP6963 from '@voltaire/provider/eip6963';

// Subscribe to wallet announcements
const unsubscribe = EIP6963.subscribe((providers) => {
  for (const { info, provider } of providers) {
    console.log(`Found: ${info.name} (${info.rdns})`);
  }
});

// Find specific wallet
const metamask = EIP6963.findProvider({ rdns: 'io.metamask' });

// Cleanup
unsubscribe();

Wallet Usage (Producer)

import * as EIP6963 from '@voltaire/provider/eip6963';

const unsubscribe = EIP6963.announce({
  info: {
    uuid: crypto.randomUUID(),
    name: "My Wallet",
    icon: "data:image/svg+xml;base64,PHN2Zy...",
    rdns: "com.mywallet"
  },
  provider: myProvider
});

See

https://eips.ethereum.org/EIPS/eip-6963

Classes

EIP6963Error

Defined in: src/provider/eip6963/errors.ts:14 Base error for all EIP-6963 operations

Extends

Extended by

Constructors

Constructor
new EIP6963Error(message, options?): EIP6963Error
Defined in: src/provider/eip6963/errors.ts:15
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
EIP6963Error
Overrides
PrimitiveError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
PrimitiveError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
PrimitiveError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
PrimitiveError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
PrimitiveError.docsPath

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
PrimitiveError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
PrimitiveError.toJSON

InvalidArgumentError

Defined in: src/provider/eip6963/errors.ts:152 Thrown when function argument is invalid

Extends

Constructors

Constructor
new InvalidArgumentError(functionName, expected, got): InvalidArgumentError
Defined in: src/provider/eip6963/errors.ts:155
Parameters
functionName
string
expected
string
got
string
Returns
InvalidArgumentError
Overrides
EIP6963Error.constructor

Properties

argument
readonly argument: string
Defined in: src/provider/eip6963/errors.ts:153
cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

InvalidFieldError

Defined in: src/provider/eip6963/errors.ts:124 Thrown when field value is invalid (e.g., empty string)

Extends

Constructors

Constructor
new InvalidFieldError(objectType, field, reason): InvalidFieldError
Defined in: src/provider/eip6963/errors.ts:127
Parameters
objectType
string
field
string
reason
string
Returns
InvalidFieldError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath
field
readonly field: string
Defined in: src/provider/eip6963/errors.ts:125

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

InvalidIconError

Defined in: src/provider/eip6963/errors.ts:88 Thrown when icon format is invalid

Extends

Constructors

Constructor
new InvalidIconError(icon): InvalidIconError
Defined in: src/provider/eip6963/errors.ts:91
Parameters
icon
string
Returns
InvalidIconError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath
icon
readonly icon: string
Defined in: src/provider/eip6963/errors.ts:89

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

InvalidProviderError

Defined in: src/provider/eip6963/errors.ts:140 Thrown when provider is invalid (missing request method)

Extends

Constructors

Constructor
new InvalidProviderError(): InvalidProviderError
Defined in: src/provider/eip6963/errors.ts:141
Returns
InvalidProviderError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

InvalidRdnsError

Defined in: src/provider/eip6963/errors.ts:69 Thrown when RDNS format is invalid

Extends

Constructors

Constructor
new InvalidRdnsError(rdns): InvalidRdnsError
Defined in: src/provider/eip6963/errors.ts:72
Parameters
rdns
string
Returns
InvalidRdnsError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath
rdns
readonly rdns: string
Defined in: src/provider/eip6963/errors.ts:70

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

InvalidUuidError

Defined in: src/provider/eip6963/errors.ts:53 Thrown when UUID format is invalid

Extends

Constructors

Constructor
new InvalidUuidError(uuid): InvalidUuidError
Defined in: src/provider/eip6963/errors.ts:56
Parameters
uuid
string
Returns
InvalidUuidError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath
uuid
readonly uuid: string
Defined in: src/provider/eip6963/errors.ts:54

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

MissingFieldError

Defined in: src/provider/eip6963/errors.ts:108 Thrown when required field is missing

Extends

Constructors

Constructor
new MissingFieldError(objectType, field): MissingFieldError
Defined in: src/provider/eip6963/errors.ts:111
Parameters
objectType
string
field
string
Returns
MissingFieldError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath
field
readonly field: string
Defined in: src/provider/eip6963/errors.ts:109

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

NotImplementedError

Defined in: src/provider/eip6963/errors.ts:168 Thrown when method is not yet implemented

Extends

Constructors

Constructor
new NotImplementedError(methodName): NotImplementedError
Defined in: src/provider/eip6963/errors.ts:169
Parameters
methodName
string
Returns
NotImplementedError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

UnsupportedEnvironmentError

Defined in: src/provider/eip6963/errors.ts:37 Thrown when EIP-6963 is used in unsupported environment

Extends

Constructors

Constructor
new UnsupportedEnvironmentError(platform): UnsupportedEnvironmentError
Defined in: src/provider/eip6963/errors.ts:40
Parameters
platform
string
Returns
UnsupportedEnvironmentError
Overrides
EIP6963Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
EIP6963Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
EIP6963Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
EIP6963Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
EIP6963Error.docsPath
platform
readonly platform: string
Defined in: src/provider/eip6963/errors.ts:38

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
EIP6963Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
EIP6963Error.toJSON

Type Aliases

Platform

Platform = "browser" | "node" | "bun" | "worker" | "unknown"
Defined in: src/provider/eip6963/types.ts:92 Platform detection result

ProviderDetailInput

ProviderDetailInput = object
Defined in: src/provider/eip6963/types.ts:79 Input type for ProviderDetail constructor

Properties

info
info: ProviderInfoInput
Defined in: src/provider/eip6963/types.ts:80
provider
provider: EIP1193Provider
Defined in: src/provider/eip6963/types.ts:81

ProviderDetailType

ProviderDetailType = Readonly<{ info: ProviderInfoType; provider: EIP1193Provider; }> & object
Defined in: src/provider/eip6963/types.ts:69 Complete provider announcement Combines provider metadata with the actual EIP-1193 provider instance. All instances are frozen and immutable.

Type Declaration

[brand]
readonly [brand]: "ProviderDetail"

Example

const detail: ProviderDetailType = EIP6963.ProviderDetail({
  info: {
    uuid: "350670db-19fa-4704-a166-e52e178b59d2",
    name: "Example Wallet",
    icon: "data:image/svg+xml;base64,PHN2Zy...",
    rdns: "com.example.wallet"
  },
  provider: window.ethereum
});

ProviderInfoInput

ProviderInfoInput = object
Defined in: src/provider/eip6963/types.ts:43 Input type for ProviderInfo constructor

Properties

icon
icon: string
Defined in: src/provider/eip6963/types.ts:46
name
name: string
Defined in: src/provider/eip6963/types.ts:45
rdns
rdns: string
Defined in: src/provider/eip6963/types.ts:47
uuid
uuid: string
Defined in: src/provider/eip6963/types.ts:44

ProviderInfoType

ProviderInfoType = Readonly<{ icon: string; name: string; rdns: string; uuid: string; }> & object
Defined in: src/provider/eip6963/types.ts:29 Wallet provider metadata Contains identifying information about an EIP-1193 provider. All instances are frozen and immutable.

Type Declaration

[brand]
readonly [brand]: "ProviderInfo"

Example

const info: ProviderInfoType = EIP6963.ProviderInfo({
  uuid: "350670db-19fa-4704-a166-e52e178b59d2",
  name: "Example Wallet",
  icon: "data:image/svg+xml;base64,PHN2Zy...",
  rdns: "com.example.wallet"
});

ProviderListener()

ProviderListener = (providers) => void
Defined in: src/provider/eip6963/types.ts:87 Listener function for provider announcements

Parameters

providers
ProviderDetailType[]

Returns

void

Variables

DATA_URI_REGEX

const DATA_URI_REGEX: RegExp
Defined in: src/provider/eip6963/validators.js:33 Data URI format regex for images

RDNS_REGEX

const RDNS_REGEX: RegExp
Defined in: src/provider/eip6963/validators.js:27 Reverse DNS format regex

UUID_V4_REGEX

const UUID_V4_REGEX: RegExp
Defined in: src/provider/eip6963/validators.js:20 UUIDv4 format regex

Functions

_reset()

_reset(): void
Defined in: src/provider/eip6963/state.js:52 Clear all state (for testing)

Returns

void

announce()

announce(detail): () => void
Defined in: src/provider/eip6963/announce.js:51 Announce a wallet provider For wallet implementations: announces the provider to dapps and automatically re-announces when dapps request providers.

Parameters

detail
ProviderDetailInput Provider info and instance

Returns

Unsubscribe function to stop announcing
(): void
Returns
void

Throws

If not in browser

Throws

If detail is missing info or provider

Throws

If provider.request is not a function

Throws

If info.uuid is not valid UUIDv4

Throws

If info.rdns is not valid reverse DNS

Throws

If info.icon is not valid data URI

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

// In wallet extension
const unsubscribe = EIP6963.announce({
  info: {
    uuid: crypto.randomUUID(),
    name: "My Wallet",
    icon: "data:image/svg+xml;base64,PHN2Zy...",
    rdns: "com.mywallet"
  },
  provider: myProvider
});

// On extension unload
unsubscribe();

assertBrowser()

assertBrowser(): void
Defined in: src/provider/eip6963/getPlatform.js:76 Assert that we’re in a browser environment

Returns

void

Throws

If not in browser

Example

import { assertBrowser } from '@voltaire/provider/eip6963';

assertBrowser(); // Throws if not in browser

findProvider()

findProvider(options): ProviderDetailType | undefined
Defined in: src/provider/eip6963/findProvider.js:42 Find a provider by its reverse DNS identifier Searches the discovered providers for one matching the given rdns. Note that this requires subscribe() to have been called at least once to start discovery.

Parameters

options
Search options
rdns
string

Returns

ProviderDetailType | undefined Matching provider or undefined

Throws

If not in browser

Throws

If options.rdns is missing

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

// Start discovery
const unsubscribe = EIP6963.subscribe(() => {});

// Find MetaMask
const metamask = EIP6963.findProvider({ rdns: 'io.metamask' });
if (metamask) {
  const accounts = await metamask.provider.request({
    method: 'eth_requestAccounts'
  });
  console.log('Connected:', accounts[0]);
}

unsubscribe();

getPlatform()

getPlatform(): "browser" | "node" | "bun" | "worker" | "unknown"
Defined in: src/provider/eip6963/getPlatform.js:33 Detect the current platform

Returns

"browser" | "node" | "bun" | "worker" | "unknown" The detected platform

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

const platform = EIP6963.getPlatform();
if (platform === 'browser') {
  // Safe to use EIP-6963
}

getProviders()

getProviders(): ProviderDetailType[]
Defined in: src/provider/eip6963/getProviders.js:34 Get snapshot of all currently discovered providers Returns the current state of discovered providers without subscribing to future updates. Note that this requires subscribe() to have been called at least once to start discovery.

Returns

ProviderDetailType[] Array of discovered providers

Throws

If not in browser

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

// Start discovery
const unsubscribe = EIP6963.subscribe(() => {});

// Get current snapshot
const providers = EIP6963.getProviders();
console.log(`Found ${providers.length} wallets`);

unsubscribe();

ProviderDetail()

ProviderDetail(input): ProviderDetailType
Defined in: src/provider/eip6963/ProviderDetail.js:48 Create a validated ProviderDetail object Validates info and provider, then returns a frozen, branded object.

Parameters

input
ProviderDetailInput Provider detail fields

Returns

ProviderDetailType Frozen, branded ProviderDetail

Throws

If info or provider is missing

Throws

If provider.request is not a function

Throws

If info.uuid is not valid UUIDv4

Throws

If info.rdns is not valid reverse DNS

Throws

If info.icon is not valid data URI

Throws

If info.name is empty

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

const detail = EIP6963.ProviderDetail({
  info: {
    uuid: "350670db-19fa-4704-a166-e52e178b59d2",
    name: "Example Wallet",
    icon: "data:image/svg+xml;base64,PHN2Zy...",
    rdns: "com.example.wallet"
  },
  provider: window.ethereum
});

// Use the provider
const accounts = await detail.provider.request({
  method: 'eth_accounts'
});

ProviderInfo()

ProviderInfo(input): ProviderInfoType
Defined in: src/provider/eip6963/ProviderInfo.js:45 Create a validated ProviderInfo object Validates all fields and returns a frozen, branded object.

Parameters

input
ProviderInfoInput Provider info fields

Returns

ProviderInfoType Frozen, branded ProviderInfo

Throws

If any required field is missing

Throws

If uuid is not valid UUIDv4

Throws

If rdns is not valid reverse DNS

Throws

If icon is not valid data URI

Throws

If name is empty

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

const info = EIP6963.ProviderInfo({
  uuid: "350670db-19fa-4704-a166-e52e178b59d2",
  name: "Example Wallet",
  icon: "data:image/svg+xml;base64,PHN2Zy...",
  rdns: "com.example.wallet"
});

console.log(info.name); // "Example Wallet"
console.log(Object.isFrozen(info)); // true

subscribe()

subscribe(listener): () => void
Defined in: src/provider/eip6963/subscribe.js:75 Subscribe to wallet provider announcements Listens for EIP-6963 provider announcements and calls the listener with the current list of discovered providers. Automatically handles deduplication by UUID (same UUID updates existing entry).

Parameters

listener
ProviderListener Called with providers array on each change

Returns

Unsubscribe function
(): void
Returns
void

Throws

If not in browser

Throws

If listener is not a function

Example

import * as EIP6963 from '@voltaire/provider/eip6963';

const unsubscribe = EIP6963.subscribe((providers) => {
  console.log('Discovered wallets:', providers.length);

  for (const { info, provider } of providers) {
    console.log(`- ${info.name} (${info.rdns})`);
  }
});

// Later, cleanup
unsubscribe();

validateIcon()

validateIcon(icon): void
Defined in: src/provider/eip6963/validators.js:99 Validate icon is a valid data URI

Parameters

icon
string The icon data URI to validate

Returns

void

Throws

If icon is missing

Throws

If icon is not a valid data URI

Example

validateIcon("data:image/svg+xml;base64,PHN2Zy..."); // OK
validateIcon("https://example.com/icon.png"); // Throws InvalidIconError

validateName()

validateName(name): void
Defined in: src/provider/eip6963/validators.js:143 Validate name is non-empty string

Parameters

name
string The name to validate

Returns

void

Throws

If name is missing

Throws

If name is empty

validateProvider()

validateProvider(provider): void
Defined in: src/provider/eip6963/validators.js:124 Validate provider has request method

Parameters

provider
unknown The provider to validate

Returns

void

Throws

If provider is missing

Throws

If provider.request is not a function

Example

validateProvider(window.ethereum); // OK if has request()
validateProvider({}); // Throws InvalidProviderError

validateRdns()

validateRdns(rdns): void
Defined in: src/provider/eip6963/validators.js:74 Validate RDNS is valid reverse DNS format

Parameters

rdns
string The reverse DNS to validate

Returns

void

Throws

If rdns is missing

Throws

If rdns is not valid format

Example

validateRdns("io.metamask"); // OK
validateRdns("metamask"); // Throws InvalidRdnsError

validateUuid()

validateUuid(uuid): void
Defined in: src/provider/eip6963/validators.js:49 Validate UUID is UUIDv4 format

Parameters

uuid
string The UUID to validate

Returns

void

Throws

If uuid is missing

Throws

If uuid is not valid UUIDv4

Example

validateUuid("350670db-19fa-4704-a166-e52e178b59d2"); // OK
validateUuid("invalid"); // Throws InvalidUuidError