Skip to content

Commit

Permalink
added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevcs committed Feb 26, 2024
1 parent 6fe67a7 commit 702def0
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 6 deletions.
58 changes: 58 additions & 0 deletions docs/docs/guides/web3_providers_guide/eip6963.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
sidebar_position: 2
sidebar_label: 'EIP-6963: Multi Injected Provider Discovery'
---

# EIP-6963: Multi Injected Provider Discovery

## Introduction

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 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.

`eip6963Providers` Map object has provider's `UUID` as keys and `EIP6963ProviderDetail` as values. `EIP6963ProviderDetail` is:

```ts
export interface EIP6963ProviderDetail {
info: EIP6963ProviderInfo;
provider: EIP1193Provider;
}
```

where `info` has details of provider containing UUID, name, Icon and RDNS as defined in EIP-6963:

```ts
export interface EIP6963ProviderInfo {
uuid: string;
name: string;
icon: string;
rdns: string;
}
```

`provider` in `EIP6963ProviderDetail` is `EIP1193Provider` and it contains actual provider that can be injected in web3 instance.

Following code snippet demonstrates usage of `requestEIP6963Providers()` function for providers discovery.

```ts
//Assuming multiple providers are installed in browser.

import { Web3 } from 'web3';

const providers = Web3.requestEIP6963Providers();

for (const [key, value] of providers) {
console.log(value);

/* 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 */

if (value.info.name === 'MetaMask') {
const web3 = new Web3(value.provider);

// now you can use web3 object with injected provider
console.log(await web3.eth.getTransaction('0x82512812c11f56aa2474a16d5cc8916b73cd6ed96bf9b8defb3499ec2d9070cb'));
}
}

```
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/events_listening.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 3
sidebar_label: 'Providers Events Listening'
---

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/http.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 4
sidebar_label: 'Tutorial: HTTP Provider'
---

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/injected_provider.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 7
sidebar_label: 'Tutorial: Injected provider'
---

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/ipc.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 6
sidebar_label: 'Tutorial: IPC Provider'
---

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/truffle.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 8
sidebar_label: 'Tutorial: Third Party Provider'
---

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/web3_providers_guide/websocket.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
sidebar_label: 'Tutorial: WebSocket Provider'
---

Expand Down

1 comment on commit 702def0

@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: 702def0 Previous: 6c075db Ratio
processingTx 9479 ops/sec (±4.50%) 9301 ops/sec (±4.81%) 0.98
processingContractDeploy 40717 ops/sec (±6.86%) 39129 ops/sec (±7.62%) 0.96
processingContractMethodSend 19188 ops/sec (±6.33%) 19443 ops/sec (±5.19%) 1.01
processingContractMethodCall 39918 ops/sec (±4.08%) 38971 ops/sec (±6.34%) 0.98
abiEncode 44367 ops/sec (±6.62%) 44252 ops/sec (±6.92%) 1.00
abiDecode 30804 ops/sec (±7.44%) 30419 ops/sec (±8.89%) 0.99
sign 1707 ops/sec (±0.78%) 1656 ops/sec (±4.08%) 0.97
verify 375 ops/sec (±2.66%) 373 ops/sec (±0.78%) 0.99

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

Please sign in to comment.