Skip to content

Commit 6edeba7

Browse files
committed
Merge branch 'main' into solana-wallet-standard
# Conflicts: # docs/whats-new.md
2 parents f639307 + 7b0a27e commit 6edeba7

File tree

837 files changed

+3884
-1371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

837 files changed

+3884
-1371
lines changed

developer-tools/dashboard/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import Banner from '@site/src/components/Banner'
99

1010
# Developer dashboard documentation
1111

12-
The MetaMask Developer dashboard provides developers with a comprehensive overview and control of their
13-
Infura service. It serves as a central hub for managing API keys and access, monitoring
14-
usage, and accessing account and billing information.
12+
The [MetaMask Developer dashboard](https://developer.metamask.io/) provides developers with a
13+
comprehensive overview and control of their Infura service.
14+
It serves as a central hub for managing API keys and access, monitoring usage, and accessing
15+
account and billing information.
1516

1617
<Banner>
1718
Don't have an API key? Sign up for a free plan and start using the Infura service!

docs/whats-new.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ of the [MetaMask developer page](https://metamask.io/developer/).
1313

1414
- Documented [Solana](/wallet/how-to/use-non-evm-networks/solana) dapp support via the Wallet Standard and third-party libraries.
1515
([#1940](https://github.com/MetaMask/metamask-docs/pull/1940))
16+
- Documented [MetaMask SDK + Web3Auth SDK integration](/sdk/quickstart/javascript-web3auth).
17+
([#2029](https://github.com/MetaMask/metamask-docs/pull/2029))
1618
- Documented [how to use the Snaps sandbox](/snaps/how-to/test-a-snap/#test-in-the-sandbox).
1719
([#2030](https://github.com/MetaMask/metamask-docs/pull/2030))
1820
- Documented how to use the SDK CLI to set up a [JavaScript + Wagmi](/sdk/quickstart/javascript-wagmi) or [Dynamic SDK](/sdk/quickstart/javascript-dynamic) project.

docusaurus.config.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4+
import fs from "fs";
45
require('dotenv').config()
56
const { themes } = require('prism-react-renderer')
67
const { REF_ALLOW_LOGIN_PATH } = require('./src/lib/constants')
@@ -13,7 +14,7 @@ const {
1314
const codeTheme = themes.dracula
1415
const remarkCodesandbox = require('remark-codesandbox')
1516
const isProd = process.env.NODE_ENV === 'production'
16-
17+
const helpDropdown = fs.readFileSync("./src/components/NavDropdown/DeveloperTools.html", "utf-8");
1718
/** @type {import('@docusaurus/types').Config} */
1819
const config = {
1920
title: 'MetaMask developer documentation',
@@ -212,14 +213,11 @@ const config = {
212213
{
213214
type: 'dropdown',
214215
label: 'Developer tools',
216+
to: 'developer-tools/dashboard',
215217
items: [
216218
{
217-
label: 'Developer dashboard',
218-
to: 'developer-tools/dashboard',
219-
},
220-
{
221-
label: 'Faucet',
222-
to: 'developer-tools/faucet',
219+
type: "html",
220+
value: helpDropdown,
223221
},
224222
],
225223
},

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"stylelint": "^15.0.0 ",
8888
"stylelint-config-standard": "^34.0.0",
8989
"tsc-files": "^1.1.4",
90-
"typescript": "^5.8.2"
90+
"typescript": "^5.8.3"
9191
},
9292
"overrides": {
9393
"react-alert": {

sdk-sidebar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const sidebar = {
2929
'quickstart/javascript-wagmi',
3030
'quickstart/javascript',
3131
'quickstart/javascript-dynamic',
32+
'quickstart/javascript-web3auth',
3233
'quickstart/react-native',
3334
],
3435
},

sdk/quickstart/javascript-dynamic.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ The project you will set up has the following structure:
4343

4444
## Prerequisites
4545

46-
- [Node.js](https://nodejs.org/) version 19 or later
47-
- [pnpm](https://pnpm.io/installation)
48-
- [MetaMask](https://metamask.io/) installed in your browser or on mobile
49-
- A [Dynamic Environment ID](https://app.dynamic.xyz/)
46+
- [Node.js](https://nodejs.org/) version 19 or later installed.
47+
- A package manager installed.
48+
The examples in this quickstart use [pnpm](https://pnpm.io/installation).
49+
- [MetaMask](https://metamask.io/) installed in your browser or on mobile.
50+
- A [Dynamic Environment ID](https://app.dynamic.xyz/).
5051

5152
## Set up using the CLI
5253

sdk/quickstart/javascript-wagmi.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ The project you will set up has the following structure:
4343

4444
## Prerequisites
4545

46-
- [Node.js](https://nodejs.org/) version 19 or later
47-
- [pnpm](https://pnpm.io/installation)
48-
- [MetaMask](https://metamask.io/) installed in your browser or on mobile
46+
- [Node.js](https://nodejs.org/) version 19 or later installed.
47+
- A package manager installed.
48+
The examples in this quickstart use [pnpm](https://pnpm.io/installation).
49+
- [MetaMask](https://metamask.io/) installed in your browser or on mobile.
4950

5051
## Set up using the CLI
5152

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
---
2+
sidebar_label: Web3Auth SDK integration
3+
description: MetaMask + Web3Auth SDK Integration
4+
toc_max_heading_level: 2
5+
---
6+
7+
# MetaMask SDK + Web3Auth SDK integration
8+
9+
Get started with MetaMask SDK and [Web3Auth SDK](https://web3auth.io/docs/).
10+
You can set up the SDKs in the following ways:
11+
12+
- [Quickstart template](#set-up-using-a-template) - Clone the template to set up a Next.js and Web3Auth dapp with both SDKs.
13+
- [Manual setup](#set-up-manually) - Set up both SDKs in an existing dapp.
14+
15+
Features include:
16+
17+
- **Dual SDK integration** - Seamlessly combine MetaMask and Web3Auth SDKs.
18+
- **Web3Auth social login** - Enable users to sign in with an email or social media account.
19+
- **Wallet connection** - Connect to MetaMask wallet with enhanced features.
20+
- **Mobile experience** - Optimized for both desktop and mobile users.
21+
- **TypeScript support** - Full type safety and modern development experience.
22+
- **Next.js integration** - Built with Next.js 15 and App Router.
23+
24+
## Prerequisites
25+
26+
- [Node.js](https://nodejs.org/) version 19 or later installed.
27+
- A package manager installed.
28+
The examples in this quickstart use [pnpm](https://pnpm.io/installation).
29+
- [MetaMask](https://metamask.io/) installed in your browser or on mobile.
30+
- A [Web3Auth Client ID](https://web3auth.io/docs/dashboard/create-new-project#get-the-client-id).
31+
32+
## Set up using a template
33+
34+
1. Download the [MetaMask SDK + Web3Auth SDK template](https://github.com/MetaMask/metamask-web3auth):
35+
36+
```bash
37+
git clone https://github.com/MetaMask/metamask-web3auth
38+
```
39+
40+
2. Navigate into the repository:
41+
42+
```bash
43+
cd metamask-web3auth
44+
```
45+
46+
3. Install dependencies:
47+
48+
```bash
49+
pnpm install
50+
```
51+
52+
4. Create a `.env.local` file:
53+
54+
```bash
55+
touch .env.local
56+
```
57+
58+
5. In `.env.local`, add a `NEXT_PUBLIC_WEB3AUTH_CLIENT_ID` environment variable, replacing `<YOUR-CLIENT-ID>` with your Web3Auth Client ID:
59+
60+
```text title=".env.local"
61+
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=<YOUR-CLIENT-ID>
62+
```
63+
64+
6. Run the project:
65+
66+
```bash
67+
pnpm dev
68+
```
69+
70+
You've successfully set up MetaMask SDK and Web3Auth SDK.
71+
See how to [use the combined SDKs](#usage).
72+
73+
## Set up manually
74+
75+
### 1. Install dependencies
76+
77+
Install the SDK and the required dependencies to an existing project:
78+
79+
```bash
80+
pnpm i viem wagmi @tanstack/react-query @web3auth/modal@10
81+
```
82+
83+
### 2. Configure providers
84+
85+
Set up your providers in `app/providers.tsx`:
86+
87+
```typescript title="providers.tsx"
88+
"use client";
89+
90+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
91+
import { type ReactNode, useState, useEffect } from "react";
92+
import { Web3AuthProvider } from "@web3auth/modal/react";
93+
import { WagmiProvider } from "@web3auth/modal/react/wagmi";
94+
import { MetaMaskSDK } from "@metamask/sdk";
95+
96+
type Props = {
97+
children: ReactNode;
98+
};
99+
100+
export function Providers({ children }: Props) {
101+
const [queryClient] = useState(() => new QueryClient());
102+
103+
useEffect(() => {
104+
if (typeof window === "undefined") return;
105+
106+
const MMSDK = new MetaMaskSDK({
107+
dappMetadata: {
108+
name: "MetaMask Web3Auth Integration",
109+
url: window.location.href,
110+
},
111+
});
112+
113+
const ethereum = MMSDK.getProvider();
114+
if (ethereum) {
115+
window.ethereum = ethereum as unknown as IEthereum;
116+
}
117+
}, []);
118+
119+
return (
120+
<Web3AuthProvider
121+
config={{
122+
web3AuthOptions: {
123+
clientId: process.env.NEXT_PUBLIC_WEB3AUTH_CLIENT_ID!,
124+
web3AuthNetwork: "sapphire_devnet"
125+
},
126+
}}
127+
>
128+
<QueryClientProvider client={queryClient}>
129+
<WagmiProvider>
130+
<div className="container">{children}</div>
131+
</WagmiProvider>
132+
</QueryClientProvider>
133+
</Web3AuthProvider>
134+
);
135+
}
136+
```
137+
138+
### 3. Set up environment variables
139+
140+
Create a `.env.local` file.
141+
In `.env.local`, add a `NEXT_PUBLIC_WEB3AUTH_CLIENT_ID` environment variable, replacing `<YOUR-CLIENT-ID>` with your Web3Auth Client ID:
142+
143+
```text title=".env.local"
144+
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=<YOUR-CLIENT-ID>
145+
```
146+
147+
You can now test your dapp by running `pnpm run dev`.
148+
149+
## Usage
150+
151+
### Connect or sign in
152+
153+
Use the `useWeb3AuthConnect` hook to enable users to connect or sign in to their wallet:
154+
155+
```typescript
156+
"use client";
157+
158+
import { useWeb3AuthConnect } from "@web3auth/modal/react";
159+
160+
export const Navbar = () => {
161+
const { connect } = useWeb3AuthConnect();
162+
163+
return (
164+
<nav>
165+
<button onClick={() => connect()}>Connect or Sign in</button>;
166+
</nav>
167+
);
168+
};
169+
```
170+
171+
### Check wallet status
172+
173+
Use the `useAccount` hook from Wagmi to check the wallet status:
174+
175+
```typescript
176+
"use client";
177+
178+
import { useAccount } from "wagmi";
179+
180+
export const Hero = () => {
181+
const { address, isConnected } = useAccount();
182+
183+
return (
184+
<div>
185+
{isConnected ? <p>Connected: {address}</p> : <p>Not connected</p>}
186+
</div>
187+
);
188+
};
189+
```
190+
191+
### Send a transaction
192+
193+
Use the `useSendTransaction` hook from Wagmi to send a transaction:
194+
195+
```typescript
196+
"use client";
197+
198+
import { useSendTransaction } from "wagmi";
199+
import { parseEther } from "viem";
200+
201+
export const SendTransaction = () => {
202+
const { sendTransaction } = useSendTransaction();
203+
204+
return (
205+
<button
206+
onClick={() =>
207+
sendTransaction({
208+
to: "0xd2135CfB216b74109775236E36d4b433F1DF507B",
209+
value: parseEther("0.001"),
210+
})
211+
}
212+
>
213+
Send transaction
214+
</button>
215+
);
216+
};
217+
```

services/get-started/infura.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ view your API key.
5050
## 3. Send requests
5151

5252
Use the API key when sending requests. The following examples interact with the Ethereum network by
53-
sending requests using HTTP:
53+
sending requests using HTTP.
5454

5555
:::info
5656

@@ -62,6 +62,23 @@ sending requests using HTTP:
6262

6363
Use a tool such as the [Client Uniform Resource Locator (curl)](../concepts/curl.md) or [Postman](https://www.postman.com/downloads/) to make requests.
6464

65+
<details>
66+
<summary>Supported API methods</summary>
67+
<div>
68+
View the supported API methods for each network in the **Reference** section in the left sidebar.
69+
The following methods are not supported on any network by Infura:
70+
71+
- `eth_coinbase`
72+
- `eth_sendTransaction`
73+
- `eth_sign`
74+
75+
Infura doesn't store the user's private key required to sign transactions.
76+
You can use [`web3.eth.sendTransaction`](https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sendtransaction),
77+
which signs the transaction locally using the private key of the account, and sends the transaction via [`web3.eth.sendSignedTransaction`](https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sendsignedtransaction),
78+
which is a wrapper for [`eth_sendRawTransaction`](../reference/ethereum/json-rpc-methods/eth_sendrawtransaction.mdx).
79+
</div>
80+
</details>
81+
6582
### 3.1 Get the current block number
6683

6784
Retrieve the current block number.

0 commit comments

Comments
 (0)