Skip to content

Commit 64c1846

Browse files
Merge branch 'MetaMask:main' into main
2 parents ca980e2 + e470f58 commit 64c1846

27 files changed

Lines changed: 424 additions & 328 deletions

File tree

embedded-wallets/build-with-ai.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ For self-hosted instances, add it to your `openclaw.json`:
9494
For any LLM tool with a system prompt or custom instructions field, paste the skill content below directly.
9595

9696
<details>
97-
<summary><strong>View `SKILL.md` file</strong></summary>
97+
<summary>View `SKILL.md` file</summary>
9898

9999
<SkillContent />
100100

gator_versioned_docs/version-1.2.0/get-started/supported-advanced-permissions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ emailing [hellogators@consensys.net](mailto:hellogators@consensys.net).
1616
| ------------------------------------------------------------------------------------------------------------------------ | ------------------ | -------------- | ----------- |
1717
| [ERC-20 periodic](../guides/advanced-permissions/use-permissions/erc20-token.md#erc-20-periodic-permission) | >= v0.1.0 | >= v13.5.0 | >= v13.23.0 |
1818
| [ERC-20 stream](../guides/advanced-permissions/use-permissions/erc20-token.md#erc-20-stream-permission) | >= v0.1.0 | >= v13.5.0 | >= v13.23.0 |
19-
| [ERC-20 revocation](../guides/advanced-permissions/use-permissions/erc20-token.md#erc-20-revocation-permission) | >= v0.3.0 | >= v13.14.0 | >= 13.18.1 |
2019
| [Native token periodic](../guides/advanced-permissions/use-permissions/native-token.md#native-token-periodic-permission) | >= v0.1.0 | >= v13.5.0 | >= v13.23.0 |
2120
| [Native token stream](../guides/advanced-permissions/use-permissions/native-token.md#native-token-stream-permission) | >= v0.1.0 | >= v13.5.0 | >= v13.23.0 |

gator_versioned_docs/version-1.2.0/guides/advanced-permissions/use-permissions/erc20-token.md

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Learn how to use the ERC-20 token permissions with Advanced Permissions (ERC-7715).
3-
keywords: [permissions, spending limit, restrict, 7715, erc-7715, erc20-permissions, revocation]
3+
keywords: [permissions, spending limit, restrict, 7715, erc-7715, erc20-permissions]
44
---
55

66
import Tabs from "@theme/Tabs";
@@ -9,7 +9,7 @@ import TabItem from "@theme/TabItem";
99
# Use ERC-20 token permissions
1010

1111
[Advanced Permissions (ERC-7715)](../../../concepts/advanced-permissions.md) supports ERC-20 token permission types that allow you to request fine-grained
12-
permissions for ERC-20 token transfers with time-based (periodic), streaming, or revocation conditions, depending on your use case.
12+
permissions for ERC-20 token transfers with time-based (periodic) or streaming conditions, depending on your use case.
1313

1414
## Prerequisites
1515

@@ -148,56 +148,3 @@ export const walletClient = createWalletClient({
148148
</TabItem>
149149
</Tabs>
150150

151-
## ERC-20 revocation permission
152-
153-
This permission type enables revoking an existing ERC-20 token allowance on behalf of the user.
154-
155-
For example, a user signs an ERC-7715 permission that lets a dapp revoke any ERC-20 token allowances
156-
periodically, or during an ongoing exploit.
157-
158-
See the [ERC-20 revocation permission API reference](../../../reference/advanced-permissions/permissions.md#erc-20-revocation-permission) for more information.
159-
160-
<Tabs>
161-
<TabItem value="example.ts">
162-
163-
```typescript
164-
import { sepolia as chain } from 'viem/chains'
165-
import { walletClient } from './client.ts'
166-
167-
// Since current time is in seconds, convert milliseconds to seconds.
168-
const currentTime = Math.floor(Date.now() / 1000)
169-
// 1 week from now.
170-
const expiry = currentTime + 604800
171-
172-
const grantedPermissions = await walletClient.requestExecutionPermissions([
173-
{
174-
chainId: chain.id,
175-
expiry,
176-
// The requested permissions will granted to the
177-
// session account.
178-
to: sessionAccount.address,
179-
permission: {
180-
type: 'erc20-token-revocation',
181-
data: {
182-
justification: 'Permission to revoke ERC-20 token allowances',
183-
},
184-
isAdjustmentAllowed: true,
185-
},
186-
},
187-
])
188-
```
189-
190-
</TabItem>
191-
<TabItem value="client.ts">
192-
193-
```typescript
194-
import { createWalletClient, custom } from 'viem'
195-
import { erc7715ProviderActions } from '@metamask/smart-accounts-kit/actions'
196-
197-
export const walletClient = createWalletClient({
198-
transport: custom(window.ethereum),
199-
}).extend(erc7715ProviderActions())
200-
```
201-
202-
</TabItem>
203-
</Tabs>

gator_versioned_docs/version-1.2.0/reference/advanced-permissions/permissions.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,6 @@ const permission = {
8585
}
8686
```
8787

88-
### ERC-20 revocation permission
89-
90-
Enables revoking an existing ERC-20 token allowance on behalf of the user.
91-
92-
#### Parameters
93-
94-
| Name | Type | Required | Description |
95-
| --------------- | -------- | -------- | ---------------------------------------------------------------------- |
96-
| `justification` | `string` | No | A human-readable explanation of why the permission is being requested. |
97-
98-
#### Example
99-
100-
```typescript
101-
const permission = {
102-
type: 'erc20-token-revocation',
103-
data: {
104-
justification: 'Permission to revoke ERC-20 token allowances',
105-
},
106-
isAdjustmentAllowed: true,
107-
}
108-
```
109-
11088
## Native token permissions
11189

11290
### Native token periodic permission

metamask-connect/evm/guides/best-practices/display.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ keywords:
1818

1919
# Display in MetaMask
2020

21+
Follow these best practices when displaying icons or method names in MetaMask.
22+
2123
## Display icons
2224

2325
When your dapp makes a sign-in request to a MetaMask user, MetaMask may render a modal that displays
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
title: 'Use Headless Mode - MetaMask Connect EVM'
3+
sidebar_label: Use headless mode
4+
description: Render a custom QR code or connection UI by using headless mode with MetaMask Connect EVM.
5+
keywords:
6+
[headless, QR code, custom UI, display_uri, evm, MetaMask, Connect, connection, modal, deeplink]
7+
---
8+
9+
# Use headless mode
10+
11+
By default, MetaMask Connect renders its own QR code modal when connecting to MetaMask Mobile
12+
via MetaMask Wallet Protocol (MWP).
13+
Headless mode suppresses this built-in modal so you can render your own connection UI.
14+
15+
Use headless mode when you want to:
16+
17+
- Display a custom-styled QR code that matches your dapp's design.
18+
- Show the connection URI in a different format (for example, a deeplink button instead of a QR code).
19+
- Integrate the connection flow into an existing modal or onboarding wizard.
20+
21+
## Prerequisites
22+
23+
Follow Step 1 of the [quickstart](../quickstart/javascript.md) to install the EVM client.
24+
25+
## Steps
26+
27+
### 1. Initialize the client with headless mode
28+
29+
Initialize an EVM client using [`createEVMClient`](../reference/methods.md#createevmclient), and set `ui.headless` to `true`:
30+
31+
```javascript
32+
import { createEVMClient, getInfuraRpcUrls } from '@metamask/connect-evm'
33+
34+
const evmClient = await createEVMClient({
35+
dapp: {
36+
name: 'My Dapp',
37+
url: window.location.href,
38+
},
39+
api: {
40+
supportedNetworks: {
41+
...getInfuraRpcUrls({ infuraApiKey: '<YOUR_INFURA_API_KEY>' }),
42+
},
43+
},
44+
ui: { headless: true },
45+
})
46+
```
47+
48+
### 2. Register a `display_uri` listener before connecting
49+
50+
The `display_uri` event fires on the EIP-1193 [provider](../reference/provider-api.md) during the connecting phase with a one-time-use pairing URI.
51+
You **must** register the listener before calling `connect`, or you may miss the event:
52+
53+
```javascript
54+
const provider = evmClient.getProvider()
55+
56+
provider.on('display_uri', uri => {
57+
showCustomQrModal(uri)
58+
})
59+
```
60+
61+
As an alternative to `provider.on`, you can pass a `displayUri` callback when initializing the client via [`eventHandlers`](../reference/methods.md#createevmclient) (see the [migration guide](migrate-from-sdk.md#6-update-event-handling)).
62+
63+
### 3. Connect and handle the result
64+
65+
Call [`connect`](../reference/methods.md#connect) to connect to MetaMask, and handle the result:
66+
67+
```javascript
68+
try {
69+
await evmClient.connect({ chainIds: ['0x1'] })
70+
hideCustomQrModal()
71+
} catch (err) {
72+
hideCustomQrModal()
73+
if (err.code === 4001) {
74+
// User rejected — show retry UI
75+
} else {
76+
console.error('Connection failed:', err)
77+
}
78+
}
79+
```
80+
81+
## Important considerations
82+
83+
### URI is one-time-use
84+
85+
The pairing URI delivered by `display_uri` is a one-time-use token.
86+
Once used or expired, it cannot be reused.
87+
If the connection fails, call `connect` again to generate a fresh URI.
88+
89+
### `display_uri` only fires during connecting
90+
91+
The event fires only while the client status is `'connecting'`.
92+
After the connection resolves (success or error), `display_uri` stops firing.
93+
94+
### Extension connections skip QR
95+
96+
When the MetaMask browser extension is installed and `ui.preferExtension` is `true` (the default),
97+
the SDK connects directly through the extension.
98+
No `display_uri` event fires because no QR code is needed.
99+
100+
To display the QR connection option even when the extension is available, set `ui.preferExtension` to `false`:
101+
102+
```javascript
103+
const evmClient = await createEVMClient({
104+
dapp: { name: 'My Dapp', url: window.location.href },
105+
api: {
106+
supportedNetworks: {
107+
...getInfuraRpcUrls({ infuraApiKey: '<YOUR_INFURA_API_KEY>' }),
108+
},
109+
},
110+
ui: {
111+
headless: true,
112+
preferExtension: false,
113+
},
114+
})
115+
```
116+
117+
### Monitor connection status
118+
119+
The EVM client exposes a [`status`](../reference/methods.md#properties) property
120+
(`'loaded' | 'pending' | 'connecting' | 'connected' | 'disconnected'`) you can read when updating UI.
121+
122+
## Next steps
123+
124+
- [Send transactions](send-transactions/index.md) in your JavaScript or Wagmi dapp.
125+
- [Sign data](sign-data/index.md) with the connected session.
126+
- See the [EVM methods reference](../reference/methods.md) for the full API.

metamask-connect/evm/guides/interact-with-contracts.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,35 @@ With MetaMask Connect EVM:
4343

4444
The following examples demonstrate how to use MetaMask Connect EVM with viem, web3.js, ethers.js, Ethereum APIs, or Wagmi to interact with Solidity smart contracts.
4545

46-
This simple Hello World contract allows anyone to read and write a message to it.
46+
## Prerequisites
4747

48-
```tsx
49-
// SPDX-License-Identifier: GPL-3.0
50-
pragma solidity >=0.7.0 <0.9.0;
48+
- Follow the [JavaScript quickstart](../quickstart/javascript.md) or [Wagmi quickstart](../quickstart/wagmi.md) to install, initialize, and connect the EVM client.
49+
- Create and deploy a simple smart contract. For example, the following contract allows anyone to read and write a message to it.
5150

52-
contract HelloWorld {
51+
<details>
52+
<summary>Hello World contract</summary>
53+
<div>
5354

54-
string public message;
55+
```tsx
56+
// SPDX-License-Identifier: GPL-3.0
57+
pragma solidity >=0.7.0 <0.9.0;
5558

56-
constructor(string memory initMessage) {
57-
message = initMessage;
58-
}
59+
contract HelloWorld {
60+
61+
string public message;
62+
63+
constructor(string memory initMessage) {
64+
message = initMessage;
65+
}
5966

60-
function update(string memory newMessage) public {
61-
message = newMessage;
67+
function update(string memory newMessage) public {
68+
message = newMessage;
69+
}
6270
}
63-
}
64-
```
71+
```
72+
73+
</div>
74+
</details>
6575

6676
## Read from contracts
6777

0 commit comments

Comments
 (0)