2.4 KiB
2.4 KiB
MetaMask Smart Account
:::warning Note: This implementation is maintained & distributed by MetaMask Smart Accounts Kit. :::
MetaMask Smart Accounts has three types of implementations, each offering unique features and use cases. See Hybrid smart account, Multisig smart account, and Stateless 7702 smart account to learn more about the implementations.
To implement MetaMask Smart Accounts, you can use the toMetaMaskSmartAccount function from the Smart Accounts Kit.
Install
:::code-group
pnpm add @metamask/smart-accounts-kit
npm install @metamask/smart-accounts-kit
yarn add @metamask/smart-accounts-kit
bun add @metamask/smart-accounts-kit
:::
Usage
:::code-group
import { // [!code focus]
Implementation, // [!code focus]
toMetaMaskSmartAccount, // [!code focus]
} from "@metamask/smart-accounts-kit" // [!code focus]
import { client } from './client.js'
import { owner } from './owner.js'
const account = await toMetaMaskSmartAccount({ // [!code focus]
client, // [!code focus]
implementation: Implementation.Hybrid, // [!code focus]
deployParams: [owner.address, [], [], []], // [!code focus]
deploySalt: "0x", // [!code focus]
signer: { account: owner }, // [!code focus]
}) // [!code focus]
import { http, createPublicClient } from 'viem'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http(),
})
import { privateKeyToAccount } from 'viem/accounts'
export const owner = privateKeyToAccount('0x...')
:::
Returns
SmartAccount<MetaMaskSmartAccountImplementation<TImplementation>>