Skip to content

Commit 3bf5d2c

Browse files
add skills
1 parent 6a76335 commit 3bf5d2c

20 files changed

Lines changed: 1643 additions & 0 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ This monorepo consists of a suite of tools to enable developers to build using t
1010
- `/smart-accounts-kit` has utilities for creating a [DeleGator SCA](https://github.com/MetaMask/delegation-framework/blob/main/documents/DeleGatorCore.md#metamasks-delegatorcore) know as MetaMask smart account, setting up delegations, and redeeming them.
1111
- `/delegator-e2e` has end-to-end tests for the Smart Accounts Kit.
1212
- `./shared` contains basic shared resources for configuring and testing the packages.
13+
- `./skills` contains agent skills that help AI coding assistants use the Smart Accounts Kit correctly.
14+
- [`/smart-accounts-kit`](./skills/smart-accounts-kit/skill.md) — build dApps with MetaMask Smart Accounts, ERC-7710 delegations, and ERC-7715 Advanced Permissions.
15+
- [`/x402-payments`](./skills/x402-payments/skill.md) — build x402 (HTTP 402) machine-to-machine payment flows using ERC-7710 delegations and ERC-7715 Advanced Permissions.
1316

1417
## Getting Started
1518

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
name: Advanced Permissions
3+
description: API reference for requesting ERC-7715 Advanced Permissions from MetaMask extension
4+
---
5+
6+
# Advanced Permissions
7+
8+
## When to use
9+
10+
- You want to request fine-grained permissions from MetaMask with a human-readable UI.
11+
- You want periodic or streaming spending allowances without per-transaction approvals.
12+
- You want to build dApps with background or automated transaction execution.
13+
14+
## API reference
15+
16+
### `requestExecutionPermissions` parameters
17+
18+
| Name | Type | Required | Description |
19+
|------|------|----------|-------------|
20+
| `chainId` | `number` | Yes | The chain ID on which the permission is being requested |
21+
| `to` | `Address` | Yes | The account to which the permission will be assigned |
22+
| `permission` | `SupportedPermissionParams` | Yes | The permission type being requested, with `isAdjustmentAllowed` flag |
23+
| `expiry` | `number` | Yes | The timestamp (in seconds) by which the permission must expire |
24+
| `from` | `Address` | No | The wallet address from which permission is requested |
25+
26+
For more details, see the [requestExecutionPermissions reference](https://docs.metamask.io/smart-accounts-kit/reference/advanced-permissions/wallet-client.md).
27+
28+
### Supported permission types
29+
30+
| Type | When to use |
31+
|------|-------------|
32+
| `erc20-token-allowance` | You want a fixed ERC-20 transfer limit that depletes until the total reaches the allowance |
33+
| `erc20-token-periodic` | You want a per-period ERC-20 limit that resets at the start of each new period |
34+
| `erc20-token-stream` | You want a linear streaming ERC-20 limit that accrues over time |
35+
| `native-token-allowance` | You want a fixed native token transfer limit that depletes until the total reaches the allowance |
36+
| `native-token-periodic` | You want a per-period native token limit that resets at the start of each new period |
37+
| `native-token-stream` | You want a linear streaming native token limit that accrues over time |
38+
| `token-approval-revocation` | You want to revoke existing token approvals (ERC-20, ERC-721, Permit2) on behalf of the user |
39+
40+
The token allowance, native token allowance, periodic, and stream permission types accept optional `startTime`, `justification`, and `isAdjustmentAllowed` parameters. The `token-approval-revocation` type only accepts `justification` and `isAdjustmentAllowed`. For full parameter details, see the [permissions reference](https://docs.metamask.io/smart-accounts-kit/reference/advanced-permissions/permissions.md).
41+
42+
### Response structure
43+
44+
```typescript
45+
{
46+
context: Hex, // Encoded permission context for redemption
47+
delegationManager: Address, // Delegation Manager address
48+
chainId: number,
49+
from: Address, // Granting address
50+
to: Hex, // Receiving address
51+
permission: PermissionTypes,
52+
dependencies: { factory: Address, factoryData: Hex }[],
53+
}
54+
```
55+
56+
## Important rules
57+
58+
- You need MetaMask Flask 13.5.0+ or MetaMask stable 13.23.0+.
59+
- The user must have a smart account — ERC-7715 creates ERC-7710 delegations under the hood.
60+
- Place `isAdjustmentAllowed` inside the `permission` object. It's always recommended.
61+
- Handle denial gracefully — provide a manual transaction fallback.
62+
- `erc20-token-revocation` is deprecated — use `token-approval-revocation` instead.
63+
64+
## Workflows
65+
66+
- [Request permissions](../workflows/request-permissions.md) — request ERC-7715 permissions from MetaMask
67+
- [Create redelegation for permissions](../workflows/create-redelegation-permissions.md) — redelegate a permission context to another account
68+
- [Redeem permissions — smart account](../workflows/redeem-permissions-smart-account.md) — redeem when the session account is a smart account
69+
- [Redeem permissions — EOA](../workflows/redeem-permissions-eoa.md) — redeem when the session account is an EOA
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
name: Delegations
3+
description: API reference for creating delegations with scopes and caveat enforcers — ERC-7710 delegation framework
4+
---
5+
6+
# Delegations
7+
8+
## When to use
9+
10+
- You want to grant permissions from one account to another (delegator to delegate).
11+
- You want to set spending limits (ERC-20, native token, NFT).
12+
- You want to restrict function calls to specific contracts or methods.
13+
- You want to add time limits, call limits, or other restrictions via caveats.
14+
- You want to create delegation chains (redelegation).
15+
16+
## API reference
17+
18+
### `createDelegation` parameters
19+
20+
| Name | Type | Required | Description |
21+
|------|------|----------|-------------|
22+
| `from` | `Hex` | Yes | The address granting the delegation |
23+
| `to` | `Hex` | Yes | The address receiving the delegation |
24+
| `scope` | `ScopeConfig` | Yes | Defines the initial authority of the delegation |
25+
| `environment` | `SmartAccountsEnvironment` | Yes | Contract addresses for framework interactions |
26+
| `caveats` | `Caveats` | No | Caveats that further refine the authority granted by the scope |
27+
| `parentDelegation` | `Delegation \| Hex` | No | Parent delegation for creating a chain (mutually exclusive with `parentPermissionContext`) |
28+
| `parentPermissionContext` | `PermissionContext` | No | Parent chain as hex or decoded values, leaf first (mutually exclusive with `parentDelegation`) |
29+
| `salt` | `Hex` | No | Salt for generating the delegation hash to prevent collisions |
30+
31+
For more details, see the [delegation reference](https://docs.metamask.io/smart-accounts-kit/reference/delegation.md).
32+
33+
### Scope types
34+
35+
Use the `ScopeType` enum for type-safe scope configuration:
36+
37+
| ScopeType | When to use |
38+
|-----------|-------------|
39+
| `Erc20TransferAmount` | You want to set a fixed cumulative ERC-20 transfer limit |
40+
| `Erc20PeriodTransfer` | You want a per-period ERC-20 limit that resets at the start of each new period |
41+
| `Erc20Streaming` | You want a linear streaming ERC-20 limit that accrues over time |
42+
| `NativeTokenTransferAmount` | You want to set a fixed cumulative native token transfer limit |
43+
| `NativeTokenPeriodTransfer` | You want a per-period native token limit that resets at the start of each new period |
44+
| `NativeTokenStreaming` | You want a linear streaming native token limit that accrues over time |
45+
| `Erc721Transfer` | You want to restrict the delegation to a specific NFT transfer |
46+
| `FunctionCall` | You want to restrict the delegation to specific methods, addresses, or calldata |
47+
| `OwnershipTransfer` | You want to restrict the delegation to ownership transfer calls only |
48+
49+
For full scope parameters, see the [delegation scopes guide](https://docs.metamask.io/smart-accounts-kit/guides/delegation/use-delegation-scopes.md).
50+
51+
### Caveat types
52+
53+
| Type | When to use |
54+
|------|-------------|
55+
| `allowedTargets` | You want to restrict which contract addresses the delegate can call |
56+
| `allowedMethods` | You want to restrict which methods the delegate can call |
57+
| `allowedCalldata` | You want to validate specific calldata at a byte offset |
58+
| `exactCalldata` | You want to require an exact calldata match |
59+
| `exactCalldataBatch` | You want to require an exact calldata match for a batch of executions |
60+
| `exactExecution` | You want to require an exact match on target, value, and calldata |
61+
| `exactExecutionBatch` | You want to require an exact match for a batch of executions |
62+
| `valueLte` | You want to cap the native token value per call |
63+
| `erc20TransferAmount` | You want to set a max cumulative ERC-20 transfer amount |
64+
| `erc20BalanceChange` | You want to validate that an ERC-20 balance changes as expected |
65+
| `erc20PeriodTransfer` | You want a per-period ERC-20 limit that resets each period |
66+
| `erc20Streaming` | You want a linear streaming ERC-20 limit that accrues over time |
67+
| `erc721Transfer` | You want to restrict the delegation to a specific NFT transfer |
68+
| `erc721BalanceChange` | You want to validate that an ERC-721 balance changes as expected |
69+
| `erc1155BalanceChange` | You want to validate that an ERC-1155 balance changes as expected |
70+
| `nativeTokenPeriodTransfer` | You want a per-period native token limit that resets each period |
71+
| `nativeTokenStreaming` | You want a linear streaming native token limit that accrues over time |
72+
| `nativeBalanceChange` | You want to validate that a native token balance changes as expected |
73+
| `nativeTokenPayment` | You want to require the redeemer to pay a fee to redeem |
74+
| `timestamp` | You want to restrict redemption to a specific time window |
75+
| `blockNumber` | You want to restrict redemption to a specific block range |
76+
| `limitedCalls` | You want to limit how many times the delegation can be redeemed |
77+
| `redeemer` | You want to restrict which addresses can redeem the delegation |
78+
| `id` | You want a one-time delegation identified by a unique ID |
79+
| `nonce` | You want to enable bulk revocation of delegations sharing the same nonce |
80+
| `deployed` | You want to auto-deploy a contract before the delegation executes |
81+
| `ownershipTransfer` | You want to restrict the delegation to ownership transfer calls only |
82+
| `multiTokenPeriod` | You want to set per-period limits across multiple tokens at once |
83+
| `specificActionERC20TransferBatch` | You want to combine a specific action with an ERC-20 transfer in a batch |
84+
| `argsEqualityCheck` | You want to validate that function arguments match a specific value |
85+
86+
For full caveat parameters, see the [caveats reference](https://docs.metamask.io/smart-accounts-kit/reference/delegation/caveats.md).
87+
88+
## Important rules
89+
90+
- The delegator must always be a MetaMask smart account created with `toMetaMaskSmartAccount`.
91+
- You must deploy the delegator before redeeming delegations — the DelegationManager reverts with `0xb9f0f171` for counterfactual accounts.
92+
- Always use caveats — without them, delegations have infinite authority.
93+
- Function call scope defaults to no native token — use `valueLte` to allow it.
94+
- Caveats are cumulative in chains — restrictions stack, and a delegate can only redelegate with equal or lesser authority.
95+
- Caveat order matters — place state-changing caveats (payment) before balance checks.
96+
- Use the `ScopeType` enum for type-safe scope configuration.
97+
98+
## Workflows
99+
100+
- [Create delegation](../workflows/create-delegation.md) — create, sign, and store a delegation
101+
- [Create redelegation](../workflows/create-redelegation.md) — delegation chains with attenuated authority
102+
- [Redeem delegation — smart account](../workflows/redeem-delegation-smart-account.md) — redeem when the delegate is a smart account
103+
- [Redeem delegation — EOA](../workflows/redeem-delegation-eoa.md) — redeem when the delegate is an EOA
104+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: Smart accounts
3+
description: API reference for creating ERC-4337 smart accounts — Hybrid, MultiSig, or Stateless7702 implementations
4+
---
5+
6+
# Smart accounts
7+
8+
## When to use
9+
10+
- You want to create an ERC-4337 smart account.
11+
- You want to configure signers (EOA private key, passkey/WebAuthn, wallet client, multisig).
12+
- You want to deploy a smart account via a bundler.
13+
- You want to choose between Hybrid, MultiSig, or Stateless7702 implementations.
14+
15+
## API reference
16+
17+
### `toMetaMaskSmartAccount` parameters
18+
19+
| Name | Type | Required | Description |
20+
|------|------|----------|-------------|
21+
| `client` | `Client` | Yes | Viem client for retrieving smart account data |
22+
| `implementation` | `Implementation` | Yes | `Hybrid`, `MultiSig`, or `Stateless7702` |
23+
| `signer` | `SignerConfigByImplementation` | No | Viem Account, Wallet Client, or WebAuthn Account (Hybrid only). Omitting disables signing operations. |
24+
| `deployParams` | `DeployParams` | If no `address` | Parameters for deployment (not needed for Stateless7702) |
25+
| `deploySalt` | `Hex` | If no `address` | Salt for deployment (not needed for Stateless7702) |
26+
| `address` | `Address` | If no `deployParams` | Existing smart account or 7702 EOA address |
27+
| `environment` | `SmartAccountsEnvironment` | No | Environment for smart contract resolution |
28+
| `nonceKeyManager` | `NonceManager` | No | Custom nonce key manager for parallel user operation execution |
29+
30+
For more details, see the [smart account reference](https://docs.metamask.io/smart-accounts-kit/reference/smart-account.md).
31+
32+
### Which implementation to use
33+
34+
| Name | Enum | Usage |
35+
|------|------|-------|
36+
| Hybrid | `Implementation.Hybrid` | A flexible account with EOA, wallet client, and passkey (WebAuthn) signers. The most flexible option for standard dApp users. |
37+
| MultiSig | `Implementation.MultiSig` | Requires multiple signers to meet a threshold before transactions execute. Best for treasury, DAO, or shared custody use cases. |
38+
| Stateless7702 | `Implementation.Stateless7702` | Upgrades an existing EOA to a smart account using EIP-7702 while keeping the same address. Best for users with existing embedded EOAs. |
39+
40+
If the user hasn't specified which implementation they need, present the options.
41+
42+
## Important rules
43+
44+
- You must deploy the account before creating delegations — use `sendUserOperation` to deploy.
45+
- `signer` is optional — if you omit it, signing operations throw.
46+
- For Hybrid `deployParams`, pass empty arrays `[]` if you don't need passkeys.
47+
- The number of MultiSig signers must be ≥ the threshold.
48+
- Stateless7702 requires an EIP-7702 upgrade first and only works with Viem local accounts.
49+
- The paymaster is optional — without it, the smart account must have funds to pay gas.
50+
51+
## Workflows
52+
53+
- [Create hybrid account](../workflows/create-hybrid-account.md) — EOA, wallet client, or passkey signers
54+
- [Create multisig account](../workflows/create-multisig-account.md) — threshold-based signing with multiple signers
55+
- [Create 7702 account](../workflows/create-7702-account.md) — upgrade an existing EOA using EIP-7702
56+
- [Create delegation](../workflows/create-delegation.md) — uses `toMetaMaskSmartAccount` to set up the delegator
57+
- [Create redelegation](../workflows/create-redelegation.md) — delegation chains across accounts
58+
- [Redeem delegation — smart account](../workflows/redeem-delegation-smart-account.md) — redeem when the delegate is a smart account
59+
- [Redeem delegation — EOA](../workflows/redeem-delegation-eoa.md) — redeem when the delegate is an EOA
60+
61+
## Docs
62+
63+
- [Smart account quickstart](https://docs.metamask.io/smart-accounts-kit/development/get-started/smart-account-quickstart.md)

0 commit comments

Comments
 (0)