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
Copy file name to clipboardExpand all lines: delegation-toolkit/concepts/delegation/caveat-enforcers.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
2
description: Learn about caveat enforcers and how they restrict delegations.
3
-
sidebar_position: 4
3
+
sidebar_position: 2
4
4
---
5
5
6
6
# Caveat enforcers
7
7
8
8
The MetaMask Delegation Toolkit provides *caveat enforcers*, which are smart contracts that implement rules and restrictions (*caveats*) on delegations.
9
-
They serve as the underlying mechanism that enables conditional execution within the [Delegation Framework](delegation.md#delegation-framework).
9
+
They serve as the underlying mechanism that enables conditional execution within the [Delegation Framework](index.md#delegation-framework).
10
10
11
11
A caveat enforcer acts as a gate that validates whether a delegation can be used for a particular execution. When a delegate attempts to execute an action on behalf of a delegator, each caveat enforcer specified in the delegation evaluates whether the execution meets its defined criteria.
12
12
@@ -119,23 +119,23 @@ This "all-or-nothing" approach ensures that delegations only execute exactly as
119
119
120
120
## Caveat builder
121
121
122
-
While caveat enforcers operate at the smart contract level, most developers interact with them through the [`CaveatBuilder`](../how-to/create-delegation/restrict-delegation.md) interface in the MetaMask Delegation Toolkit.
122
+
While caveat enforcers operate at the smart contract level, most developers interact with them through the [`CaveatBuilder`](../../guides/delegation/restrict-delegation.md) interface in the MetaMask Delegation Toolkit.
123
123
124
124
The `CaveatBuilder` provides a developer-friendly TypeScript API that:
125
125
126
126
- Abstracts away the complexity of correctly formatting and encoding caveat terms.
127
127
- Provides type-checking and validation for caveat parameters.
128
128
- Handles the creation of the `caveats` array needed when creating a delegation.
129
129
130
-
Each [caveat type](../reference/caveats.md) in the `CaveatBuilder`
130
+
Each [caveat type](../../reference/caveats.md) in the `CaveatBuilder`
131
131
corresponds to a specific caveat enforcer contract. For example, when you use:
The builder is creating a caveat that references the
138
-
[`AllowedTargetsEnforcer`](../reference/caveats.md#allowedtargets) contract address and
138
+
[`AllowedTargetsEnforcer`](../../reference/caveats.md#allowedtargets) contract address and
139
139
properly encodes the provided addresses as terms for that enforcer.
140
140
141
141
## Caveat enforcer best practices
@@ -145,26 +145,26 @@ When designing delegations with caveats, consider these best practices:
145
145
-**Combine caveat enforcers appropriately** - Use multiple caveat enforcers to create comprehensive restrictions.
146
146
147
147
-**Consider caveat enforcer order** - When using caveat enforcers that modify external contract states, the order matters.
148
-
For example, using [`NativeTokenPaymentEnforcer`](../reference/caveats.md#nativetokenpayment) before
149
-
[`NativeBalanceChangeEnforcer`](../reference/caveats.md#nativebalancechange) might cause validation failures.
148
+
For example, using [`NativeTokenPaymentEnforcer`](../../reference/caveats.md#nativetokenpayment) before
149
+
[`NativeBalanceChangeEnforcer`](../../reference/caveats.md#nativebalancechange) might cause validation failures.
150
150
151
151
-**Be careful with unbounded delegations** - Always include appropriate caveat enforcers to limit what a delegate can do.
152
152
153
153
## Available caveat enforcers
154
154
155
-
The Delegation Toolkit provides [many out-of-the-box caveat enforcers](../reference/caveats.md)
155
+
The Delegation Toolkit provides [out-of-the-box caveat enforcers](../../reference/caveats.md)
156
156
for common restriction patterns, including:
157
157
158
158
- Limiting target addresses and methods.
159
159
- Setting time or block number constraints.
160
160
- Restricting token transfers and approvals.
161
161
- Limiting execution frequency.
162
162
163
-
For more complex scenarios, you can also [create custom caveat enforcers](../how-to/create-delegation/create-custom-caveat-enforcer.md) by implementing the `ICaveatEnforcer` interface.
163
+
For other restriction patterns, you can also [create custom caveat enforcers](../../tutorials/create-custom-caveat-enforcer.md) by implementing the `ICaveatEnforcer` interface.
164
164
165
165
## Attenuating authority with redelegations
166
166
167
-
When [creating chains of delegations](../how-to/create-delegation/index.md#create-a-redelegation), it's important to understand how authority flows and can be restricted.
167
+
When creating chains of delegations via [redelegations](index.md#delegation-types), it's important to understand how authority flows and can be restricted.
168
168
169
169
Caveats applied to a chain of delegations are *accumulative*—they stack on top of each other:
0 commit comments