Skip to content

Commit cc625d2

Browse files
docs: add MetaMask smart account documentation (#3699)
add metamask smart account documentation
1 parent 20b1ed2 commit cc625d2

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# MetaMask Smart Account
2+
3+
:::warning
4+
**Note:** This implementation is maintained & distributed by [MetaMask Delegation Toolkit](https://docs.gator.metamask.io).
5+
:::
6+
7+
MetaMask Smart Account has two types of implementations, each offering unique features
8+
and use cases. See [Hybrid Smart Account](https://docs.gator.metamask.io/how-to/create-smart-account/configure-accounts-signers#configure-a-hybrid-smart-account) and [MultiSig Smart Account](https://docs.gator.metamask.io/how-to/create-smart-account/configure-accounts-signers#configure-a-multisig-smart-account) to learn more about
9+
the implementations.
10+
11+
To implement MetaMask Smart Account, you can use the [`toMetaMaskSamrtAccount`](https://docs.gator.metamask.io/how-to/create-smart-account#create-a-metamasksmartaccount) function from [delegation toolkit](https://docs.gator.metamask.io).
12+
13+
## Install
14+
15+
:::code-group
16+
```bash [pnpm]
17+
pnpm add @metamask/delegation-toolkit
18+
```
19+
20+
```bash [npm]
21+
npm install @metamask/delegation-toolkit
22+
```
23+
24+
```bash [yarn]
25+
yarn add @metamask/delegation-toolkit
26+
```
27+
28+
```bash [bun]
29+
bun add @metamask/delegation-toolkit
30+
```
31+
:::
32+
33+
## Usage
34+
35+
:::code-group
36+
37+
```ts twoslash [example.ts]
38+
import { // [!code focus]
39+
Implementation, // [!code focus]
40+
toMetaMaskSmartAccount, // [!code focus]
41+
} from "@metamask/delegation-toolkit" // [!code focus]
42+
import { client } from './client.js'
43+
import { owner } from './owner.js'
44+
45+
const account = await toMetaMaskSmartAccount({ // [!code focus]
46+
client, // [!code focus]
47+
implementation: Implementation.Hybrid, // [!code focus]
48+
deployParams: [owner.address, [], [], []], // [!code focus]
49+
deploySalt: "0x", // [!code focus]
50+
signatory: { account: owner }, // [!code focus]
51+
}) // [!code focus]
52+
```
53+
54+
```ts twoslash [client.ts] filename="config.ts"
55+
import { http, createPublicClient } from 'viem'
56+
import { mainnet } from 'viem/chains'
57+
58+
export const client = createPublicClient({
59+
chain: mainnet,
60+
transport: http(),
61+
})
62+
```
63+
64+
```ts twoslash [owner.ts (Private Key)] filename="owner.ts"
65+
import { privateKeyToAccount } from 'viem/accounts'
66+
67+
export const owner = privateKeyToAccount('0x...')
68+
```
69+
:::
70+
71+
## Returns
72+
73+
`SmartAccount<MetaMaskSmartAccountImplementation<TImplementation>>`
74+
75+
## Parameters
76+
77+
[See Parameters](https://docs.gator.metamask.io/reference/delegation-toolkit-api/smart-account#parameters-5)
78+

site/sidebar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,10 @@ export const sidebar = {
12221222
text: 'Coinbase',
12231223
link: '/account-abstraction/accounts/smart/toCoinbaseSmartAccount',
12241224
},
1225+
{
1226+
text: 'MetaMask',
1227+
link: '/account-abstraction/accounts/smart/toMetaMaskSmartAccount',
1228+
},
12251229
{
12261230
text: 'Thirdweb',
12271231
link: '/account-abstraction/accounts/smart/toThirdwebSmartAccount',

0 commit comments

Comments
 (0)