Skip to content

Commit

Permalink
updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevcs committed Mar 5, 2024
1 parent 8d963d9 commit 91948c2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/docs/guides/web3_providers_guide/eip6963.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, EIP6963ProviderDetail>` 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<string, EIP6963ProviderDetail>` 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:

Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 91948c2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 91948c2 Previous: 6c075db Ratio
processingTx 9581 ops/sec (±4.09%) 9301 ops/sec (±4.81%) 0.97
processingContractDeploy 42925 ops/sec (±7.13%) 39129 ops/sec (±7.62%) 0.91
processingContractMethodSend 20810 ops/sec (±6.40%) 19443 ops/sec (±5.19%) 0.93
processingContractMethodCall 41184 ops/sec (±5.68%) 38971 ops/sec (±6.34%) 0.95
abiEncode 46384 ops/sec (±7.36%) 44252 ops/sec (±6.92%) 0.95
abiDecode 32230 ops/sec (±7.63%) 30419 ops/sec (±8.89%) 0.94
sign 1662 ops/sec (±3.87%) 1656 ops/sec (±4.08%) 1.00
verify 375 ops/sec (±0.48%) 373 ops/sec (±0.78%) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.