Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 702def0

Browse files
committed
added doc
1 parent 6fe67a7 commit 702def0

7 files changed

Lines changed: 64 additions & 6 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
sidebar_position: 2
3+
sidebar_label: 'EIP-6963: Multi Injected Provider Discovery'
4+
---
5+
6+
# EIP-6963: Multi Injected Provider Discovery
7+
8+
## Introduction
9+
10+
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.
11+
12+
Web3.js library has utility function for discovery of injected providers using `requestEIP6963Providers()` function. When `requestEIP6963Providers()` is used it returns `eip6963Providers` Map object. This Map object is in global scope so every time `requestEIP6963Providers()` function is called it will update Map object and return it.
13+
14+
`eip6963Providers` Map object has provider's `UUID` as keys and `EIP6963ProviderDetail` as values. `EIP6963ProviderDetail` is:
15+
16+
```ts
17+
export interface EIP6963ProviderDetail {
18+
info: EIP6963ProviderInfo;
19+
provider: EIP1193Provider;
20+
}
21+
```
22+
23+
where `info` has details of provider containing UUID, name, Icon and RDNS as defined in EIP-6963:
24+
25+
```ts
26+
export interface EIP6963ProviderInfo {
27+
uuid: string;
28+
name: string;
29+
icon: string;
30+
rdns: string;
31+
}
32+
```
33+
34+
`provider` in `EIP6963ProviderDetail` is `EIP1193Provider` and it contains actual provider that can be injected in web3 instance.
35+
36+
Following code snippet demonstrates usage of `requestEIP6963Providers()` function for providers discovery.
37+
38+
```ts
39+
//Assuming multiple providers are installed in browser.
40+
41+
import { Web3 } from 'web3';
42+
43+
const providers = Web3.requestEIP6963Providers();
44+
45+
for (const [key, value] of providers) {
46+
console.log(value);
47+
48+
/* Based on your DApp's logic show use list of providers and get selected provider's UUID from user for injecting its EIP6963ProviderDetail.provider EIP1193 object into web3 object */
49+
50+
if (value.info.name === 'MetaMask') {
51+
const web3 = new Web3(value.provider);
52+
53+
// now you can use web3 object with injected provider
54+
console.log(await web3.eth.getTransaction('0x82512812c11f56aa2474a16d5cc8916b73cd6ed96bf9b8defb3499ec2d9070cb'));
55+
}
56+
}
57+
58+
```

docs/docs/guides/web3_providers_guide/events_listening.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 2
2+
sidebar_position: 3
33
sidebar_label: 'Providers Events Listening'
44
---
55

docs/docs/guides/web3_providers_guide/http.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 3
2+
sidebar_position: 4
33
sidebar_label: 'Tutorial: HTTP Provider'
44
---
55

docs/docs/guides/web3_providers_guide/injected_provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 7
33
sidebar_label: 'Tutorial: Injected provider'
44
---
55

docs/docs/guides/web3_providers_guide/ipc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 5
2+
sidebar_position: 6
33
sidebar_label: 'Tutorial: IPC Provider'
44
---
55

docs/docs/guides/web3_providers_guide/truffle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 7
2+
sidebar_position: 8
33
sidebar_label: 'Tutorial: Third Party Provider'
44
---
55

docs/docs/guides/web3_providers_guide/websocket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 5
33
sidebar_label: 'Tutorial: WebSocket Provider'
44
---
55

0 commit comments

Comments
 (0)