Skip to content

Commit efe786a

Browse files
authored
chore(docs): readme-symlink (#25)
1 parent 51cca21 commit efe786a

File tree

1 file changed

+120
-1
lines changed

1 file changed

+120
-1
lines changed
Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,122 @@
11
# Web3.js Plugin for Wallet RPC methods
22

3-
Refer to the [README](https://github.com/web3/web3-plugin-wallet-rpc/blob/main/README.md) file located in the root of this repository.
3+
This Web3.js plugin adds support for the following wallet-related RPC methods:
4+
5+
- [wallet_addEthereumChain (EIP-3085)](https://eips.ethereum.org/EIPS/eip-3085)
6+
- [wallet_switchEthereumChain (EIP-3326)](https://eips.ethereum.org/EIPS/eip-3326)
7+
- [wallet_watchAsset (EIP-747)](https://eips.ethereum.org/EIPS/eip-747)
8+
- [wallet_requestPermissions (EIP-2255)](https://eips.ethereum.org/EIPS/eip-2255)
9+
- [wallet_getPermissions (EIP-2255)](https://eips.ethereum.org/EIPS/eip-2255)
10+
- [wallet_revokePermissions](https://docs.metamask.io/wallet/reference/json-rpc-methods/wallet_revokepermissions/)
11+
12+
Keep reading for more information, or refer to the comprehensive [API documentation](https://web3.github.io/web3-plugin-wallet-rpc/).
13+
14+
## Installation
15+
16+
Use your preferred package manager. Ensure that `web3` is also installed and integrated into your project.
17+
18+
```bash
19+
npm install web3-plugin-wallet-rpc
20+
```
21+
22+
```bash
23+
yarn add web3-plugin-wallet-rpc
24+
```
25+
26+
```bash
27+
pnpm add web3-plugin-wallet-rpc
28+
```
29+
30+
## Usage
31+
32+
### Register plugin
33+
34+
```typescript
35+
import { Web3 } from 'web3';
36+
import { WalletRpcPlugin } from 'web3-plugin-wallet-rpc';
37+
38+
const web3 = new Web3('https://eth.llamarpc.com');
39+
web3.registerPlugin(new WalletRpcPlugin());
40+
```
41+
42+
### Methods
43+
44+
Click on the method name for detailed documentation.
45+
46+
#### [addEthereumChain](https://web3.github.io/web3-plugin-wallet-rpc/classes/WalletRpcPlugin.html#addEthereumChain)
47+
48+
Invokes the `wallet_addEthereumChain` method as defined in [EIP-3085](https://eips.ethereum.org/EIPS/eip-3085#wallet_addethereumchain).
49+
50+
```typescript
51+
await web3.walletRpc.addEthereumChain({
52+
chainId: 5000,
53+
blockExplorerUrls: ['https://mantlescan.xyz'],
54+
chainName: 'Mantle',
55+
iconUrls: ['https://icons.llamao.fi/icons/chains/rsz_mantle.jpg'],
56+
nativeCurrency: {
57+
name: 'Mantle',
58+
symbol: 'MNT',
59+
decimals: 18,
60+
},
61+
rpcUrls: ['https://rpc.mantle.xyz'],
62+
});
63+
```
64+
65+
#### [switchEthereumChain](https://web3.github.io/web3-plugin-wallet-rpc/classes/WalletRpcPlugin.html#switchEthereumChain)
66+
67+
Invokes the `wallet_switchEthereumChain` method as defined in [EIP-3326](https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain).
68+
69+
```typescript
70+
await web3.walletRpc.switchEthereumChain(5000);
71+
```
72+
73+
#### [watchAsset](https://web3.github.io/web3-plugin-wallet-rpc/classes/WalletRpcPlugin.html#watchAsset)
74+
75+
Invokes the `wallet_watchAsset` method as defined in [EIP-747](https://eips.ethereum.org/EIPS/eip-747#specification).
76+
77+
```typescript
78+
await web3.walletRpc.watchAsset({
79+
type: 'ERC20',
80+
options: {
81+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
82+
symbol: 'USDC',
83+
},
84+
});
85+
```
86+
87+
#### [requestPermissions](https://web3.github.io/web3-plugin-wallet-rpc/classes/WalletRpcPlugin.html#requestPermissions)
88+
89+
Invokes the `wallet_requestPermissions` method as defined in [EIP-2255](https://eips.ethereum.org/EIPS/eip-2255#specification).
90+
91+
```typescript
92+
const permissions = await web3.walletRpc.requestPermissions({
93+
eth_accounts: {},
94+
});
95+
```
96+
97+
#### [getPermissions](https://web3.github.io/web3-plugin-wallet-rpc/classes/WalletRpcPlugin.html#getPermissions)
98+
99+
Invokes the `wallet_getPermissions` method as defined in [EIP-2255](https://eips.ethereum.org/EIPS/eip-2255#specification).
100+
101+
```typescript
102+
const permissions = await web3.walletRpc.getPermissions();
103+
```
104+
105+
#### [revokePermissions](https://web3.github.io/web3-plugin-wallet-rpc/classes/WalletRpcPlugin.html#revokePermissions)
106+
107+
Invokes the `wallet_revokePermissions` method as defined in [MetaMask docs](https://docs.metamask.io/wallet/reference/json-rpc-methods/wallet_revokepermissions/).
108+
109+
```typescript
110+
const permissions = await web3.walletRpc.revokePermissions({
111+
eth_accounts: {},
112+
});
113+
```
114+
115+
## Contributing
116+
117+
We welcome pull requests! For major changes, please [open an issue](https://github.com/web3/web3-plugin-wallet-rpc) first to discuss the proposed modifications.
118+
Also, ensure that you update tests as needed to reflect the changes.
119+
120+
## License
121+
122+
[MIT](https://choosealicense.com/licenses/mit/)

0 commit comments

Comments
 (0)