diff --git a/docs/docs/guides/web3_providers_guide/eip6963.md b/docs/docs/guides/web3_providers_guide/eip6963.md index fcf63242584..0965e440c9b 100644 --- a/docs/docs/guides/web3_providers_guide/eip6963.md +++ b/docs/docs/guides/web3_providers_guide/eip6963.md @@ -9,7 +9,9 @@ sidebar_label: 'EIP-6963: Multi Injected Provider Discovery' EIP-6963 proposes the "Multi Injected Provider Discovery" standard, which aims to enhance the discoverability and interaction with multiple injected Ethereum providers in a browser environment. Injected providers refer to browser extensions or other injected scripts that provide access to an Ethereum provider within the context of a web application. -Web3.js library has utility function for discovery of injected providers using `requestEIP6963Providers()` function. When `requestEIP6963Providers()` is called it returns Promise object that resolves to `Map` object containing list of providers. For updated providers `eip6963:providersMapUpdated` event is emitted and it has updated Map object. +Web3.js library has utility functions for discovery of injected providers using `requestEIP6963Providers()` and `onNewProviderDiscovered(eventDetails)`. + +`onNewProviderDiscovered(eventDetails)` can be used to subscribe to events of provider discovery & providers map update and `requestEIP6963Providers()` returns Promise object that resolves to `Map` object containing list of providers. For updated providers `eip6963:providersMapUpdated` event is emitted and it has updated Map object. This event can be subscribed as mentioned earlier using `onNewProviderDiscovered(eventDetails)` `eip6963ProvidersMap` object has provider's `UUID` as keys and `EIP6963ProviderDetail` as values. `EIP6963ProviderDetail` is: @@ -40,9 +42,11 @@ Following code snippet demonstrates usage of `requestEIP6963Providers()` functio import { Web3 } from 'web3'; -window.addEventListener('web3:providersMapUpdated', (event) => { - console.log(event.detail); // This will log the populated providers map object - // add logic here for updating UI of your DApp +// Following will subscribe to event that will be triggered when providers map is updated. + +Web3.onNewProviderDiscovered((provider) => { + console.log(provider.detail); // This will log the populated providers map object, provider.detail has Map of all providers yet discovered + // add logic here for updating UI of your DApp }); // Call the function and wait for the promise to resolve