-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
--- | ||
|
||
|
702def0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
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.