You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial walks you through creating a custom [caveat enforcer](/delegation-toolkit/concepts/delegation/caveat-enforcers) and applying it to a [delegation](/delegation-toolkit/concepts/delegation/).
10
14
11
-
This tutorial walks you through creating a custom [caveat enforcer](../concepts/delegation/caveat-enforcers.md) and applying it to a [delegation](../concepts/delegation/index.md).
12
-
13
-
The MetaMask Delegation Toolkit includes [out-of-the-box caveat enforcers](../reference/caveats.md) that define rules and restrictions for common use cases.
15
+
The MetaMask Delegation Toolkit includes [out-of-the-box caveat enforcers](/delegation-toolkit/reference/caveats) that define rules and restrictions for common use cases.
14
16
For more specific control or other use cases, you can create custom caveat enforcers.
15
17
In this tutorial, you'll create and apply a caveat enforcer that only allows a delegation to be redeemed after a specific timestamp.
16
18
17
19
## Prerequisites
18
20
19
-
-[Install and set up the Delegation Toolkit](../get-started/install.md) in your project.
20
-
-[Configure the Delegation Toolkit.](../guides/configure.md)
21
+
-[Install and set up the Delegation Toolkit](/delegation-toolkit/get-started/install) in your project.
22
+
-[Configure the Delegation Toolkit.](/delegation-toolkit/guides/configure)
21
23
-[Install Foundry and Forge.](https://getfoundry.sh/introduction/installation)
22
24
- Get an [Infura API key](/developer-tools/dashboard/get-started/create-api) from the MetaMask Developer dashboard.
23
25
- Have a MetaMask account with some Sepolia ETH to deploy your contract.
@@ -41,7 +43,7 @@ interface and only allows a delegation to be redeemed after a specific timestamp
41
43
pragma solidity 0.8.23;
42
44
43
45
import { CaveatEnforcer } from "@delegator/src/enforcers/CaveatEnforcer.sol";
44
-
import { ModeCode } from "../utils/Types.sol";
46
+
import { ModeCode } from "/delegation-toolkit/utils/Types.sol";
45
47
46
48
contract AfterTimestampEnforcer is CaveatEnforcer {
47
49
/**
@@ -90,7 +92,7 @@ The Forge CLI will display the address of the deployed caveat enforcer.
90
92
### 3. Apply the caveat enforcer
91
93
92
94
Specify the address of the deployed `AfterTimestampEnforcer.sol` contract, add it to the caveat builder, and create a delegation.
93
-
Learn more about [applying caveats to a delegation](../guides/delegation/restrict-delegation.md).
95
+
Learn more about [applying caveats to a delegation](/delegation-toolkit/guides/delegation/restrict-delegation).
94
96
95
97
The following code snippet uses the custom caveat enforcer to create a delegation granting
96
98
a 1,000,000 wei allowance that becomes spendable one hour after it is created:
@@ -99,63 +101,55 @@ a 1,000,000 wei allowance that becomes spendable one hour after it is created:
This tutorial walks you through using a passkey as a backup signer for your [MetaMask smart account](../concepts/smart-accounts).
11
+
This tutorial walks you through using a passkey as a backup signer for your [MetaMask smart account](/delegation-toolkit/concepts/smart-accounts.md).
9
12
10
13
## About passkeys
11
14
12
15
An externally owned account (EOA) uses the secp256k1 elliptic curve to generate key pairs and signatures.
13
16
In contrast, a passkey (WebAuthn credential) uses the secp256r1 (P-256) elliptic curve to generate key pairs and signatures.
14
17
Passkeys eliminate the need for traditional seed phrases that are difficult to remember, enabling a more seamless and secure way for users to access their web3 wallets.
15
18
16
-
MetaMask Smart Accounts offer a [Hybrid implementation](../concepts/smart-accounts.md#hybrid-smart-account), which supports signature validation for both secp256k1 and secp256r1 curves.
19
+
MetaMask Smart Accounts offer a [Hybrid implementation](/delegation-toolkit/concepts/smart-accounts.md#hybrid-smart-account), which supports signature validation for both secp256k1 and secp256r1 curves.
17
20
This allows you to add a passkey as a backup signer for your smart account.
18
21
19
22
You can add passkeys during smart account creation or after the account has been deployed.
20
23
This tutorial walks you through adding a passkey signer to an already deployed smart account.
21
24
22
25
## Prerequisites
23
26
24
-
-[Install and set up the Delegation Toolkit](../get-started/install) in your project.
27
+
-[Install and set up the Delegation Toolkit](/delegation-toolkit/get-started/install.md) in your project.
-[Configure the Delegation Toolkit](../guides/configure).
27
-
-[Create and deploy a Hybrid smart account,](../guides/smart-accounts/create-smart-account) with a signatory from a private key.
29
+
-[Configure the Delegation Toolkit](/delegation-toolkit/guides/configure.md).
30
+
-[Create and deploy a Hybrid smart account,](/delegation-toolkit/guides/smart-accounts/create-smart-account.md) with a signatory from a private key.
28
31
29
32
## Steps
30
33
@@ -34,13 +37,13 @@ Create a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's
34
37
You will configure a smart account and Bundler Client with the Public Client, which you can use to query the signer's account state and interact with the blockchain network.
35
38
36
39
```typescript
37
-
import { createPublicClient, http } from"viem";
38
-
import { sepoliaaschain } from"viem/chains";
40
+
import { createPublicClient, http } from'viem'
41
+
import { sepoliaaschain } from'viem/chains'
39
42
40
43
const publicClient =createPublicClient({
41
44
chain,
42
45
transport: http(),
43
-
});
46
+
})
44
47
```
45
48
46
49
### 2. Create a Bundler Client
@@ -49,46 +52,44 @@ Create a [Viem Bundler Client](https://viem.sh/account-abstraction/clients/bundl
49
52
You can use the bundler service to estimate gas for user operations and submit transactions to the network.
Configure the same [Hybrid smart account](../guides/smart-accounts/create-smart-account.md#create-a-hybrid-smart-account) that you created and deployed as a [prerequisite](#prerequisites).
65
+
Configure the same [Hybrid smart account](/delegation-toolkit/guides/smart-accounts/create-smart-account.md#create-a-hybrid-smart-account) that you created and deployed as a [prerequisite](#prerequisites).
63
66
The Hybrid implementation supports adding additional passkey signers.
To add a passkey signer, use Viem's [`createWebAuthnCredential`](https://viem.sh/account-abstraction/accounts/webauthn/createWebAuthnCredential) function to securely register the passkey (WebAuthn credential).
- See [Create a MetaMask smart account](../guides/smart-accounts/create-smart-account.md) to learn more about smart account implementations.
167
-
- See [Send a gasless transaction](../guides/smart-accounts/send-gasless-transaction.md) to learn how to sponsor gas fees when adding a passkey as a backup signer.
167
+
- See [Create a MetaMask smart account](/delegation-toolkit/guides/smart-accounts/create-smart-account.md) to learn more about smart account implementations.
168
+
- See [Send a gasless transaction](/delegation-toolkit/guides/smart-accounts/send-gasless-transaction.md) to learn how to sponsor gas fees when adding a passkey as a backup signer.
0 commit comments