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/guides/delegation/use-delegation-scopes/function-call.md
+88-7Lines changed: 88 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,14 @@ description: Learn how to use the function call scope for a delegation.
3
3
keywords: [delegation scope, function call, restrict, delegation]
4
4
---
5
5
6
+
import Tabs from "@theme/Tabs";
7
+
import TabItem from "@theme/TabItem";
8
+
6
9
# Use the function call scope
7
10
8
11
The function call scope defines the specific methods, contract addresses, and calldata that are allowed for the delegation.
9
12
For example, Alice delegates to Bob the ability to call the `approve` function on the USDC contract, with the approval amount set to `0`.
10
13
11
-
Internally, this scope uses the [`allowedTargets`](../../../reference/delegation/caveats.md#allowedtargets) and [`allowedMethods`](../../../reference/delegation/caveats.md#allowedmethods) caveat enforcers, and
12
-
optionally uses the [`allowedCalldata`](../../../reference/delegation/caveats.md#allowedcalldata) or [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) caveat enforcers when those parameters are specified.
13
-
14
14
## Prerequisites
15
15
16
16
-[Install and set up the Delegation Toolkit.](../../../get-started/install.md)
@@ -20,10 +20,13 @@ optionally uses the [`allowedCalldata`](../../../reference/delegation/caveats.md
20
20
21
21
## Function call scope
22
22
23
-
This scope requires `targets` and `selectors` as mandatory parameters for the configuration.
24
-
You can specify the allowed methods in `selectors` and the permitted contract addresses in `targets`.
23
+
This scope requires `targets`, which specifies the permitted contract addresses, and `selectors`, which specifies the allowed methods.
24
+
25
+
Internally, this scope uses the [`allowedTargets`](../../../reference/delegation/caveats.md#allowedtargets) and [`allowedMethods`](../../../reference/delegation/caveats.md#allowedmethods) caveat enforcers, and
26
+
optionally uses the [`allowedCalldata`](../../../reference/delegation/caveats.md#allowedcalldata) or [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) caveat enforcers when those parameters are specified.
27
+
See the [function call scope reference](../../../reference/delegation/delegation-scopes.md#function-call-scope) for more details.
25
28
26
-
The following example sets the delegation scope to allow the delegate to call the `approve` function on the USDC token contract.
29
+
The following example sets the delegation scope to allow the delegate to call the `approve` function on the USDC token contract:
Copy file name to clipboardExpand all lines: delegation-toolkit/guides/delegation/use-delegation-scopes/spending-limit.md
+26-10Lines changed: 26 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,15 @@ You can set transfer limits with or without time-based (periodic) or streaming c
18
18
## ERC-20 periodic scope
19
19
20
20
This scope ensures a per-period limit for ERC-20 token transfers.
21
-
You set the amountand the time window.
21
+
You set the amount, period, and start data.
22
22
At the start of each new period, the allowance resets.
23
23
For example, Alice creates a delegation that lets Bob spend up to 10 USDC on her behalf each day.
24
24
Bob can transfer a total of 10 USDC per day; the limit resets at the beginning of the next day.
25
25
26
26
When this scope is applied, the toolkit automatically disallows native token transfers (sets the native token transfer limit to `0`).
27
27
28
28
Internally, this scope uses the [`erc20PeriodTransfer`](../../../reference/delegation/caveats.md#erc20periodtransfer) and [`valueLte`](../../../reference/delegation/caveats.md#valuelte) caveat enforcers.
29
+
See the [ERC-20 periodic scope reference](../../../reference/delegation/delegation-scopes.md#erc-20-periodic-scope) for more details.
@@ -59,6 +60,7 @@ For example, Alice creates a delegation that allows Bob to spend 0.1 USDC per se
59
60
When this scope is applied, the toolkit automatically disallows native token transfers (sets the native token transfer limit to `0`).
60
61
61
62
Internally, this scope uses the [`erc20Streaming`](../../../reference/delegation/caveats.md#erc20streaming) and [`valueLte`](../../../reference/delegation/caveats.md#valuelte) caveat enforcers.
63
+
See the [ERC-20 streaming scope reference](../../../reference/delegation/delegation-scopes.md#erc-20-streaming-scope) for more details.
This scope ensures that ERC-20 token transfers are limited to a predefined maximum amount.
89
-
This scope is useful for setting simple, fixed transfer limits without any timebased or streaming conditions.
91
+
This scope is useful for setting simple, fixed transfer limits without any time-based or streaming conditions.
90
92
For example, Alice creates a delegation that allows Bob to spend up to 10 USDC without any conditions.
91
93
Bob may use the 10 USDC in a single transaction or make multiple transactions, as long as the total does not exceed 10 USDC.
92
94
93
95
When this scope is applied, the toolkit automatically disallows native token transfers (sets the native token transfer limit to `0`).
94
96
95
97
Internally, this scope uses the [`erc20TransferAmount`](../../../reference/delegation/caveats.md#erc20transferamount) and [`valueLte`](../../../reference/delegation/caveats.md#valuelte) caveat enforcers.
98
+
See the [ERC-20 transfer scope reference](../../../reference/delegation/delegation-scopes.md#erc-20-transfer-scope) for more details.
This scope ensures a per-period limit for native token transfers.
139
-
You set the amountand the time window.
143
+
You set the amount, period, and start date.
140
144
At the start of each new period, the allowance resets.
141
145
For example, Alice creates a delegation that lets Bob spend up to 0.01 ETH on her behalf each day.
142
146
Bob can transfer a total of 0.01 ETH per day; the limit resets at the beginning of the next day.
143
147
144
-
When this scope is applied, the toolkit disallows ERC-20 and ERC-721 token transfers by default, setting the allowed `calldata` to `0x`.
148
+
When this scope is applied, the toolkit disallows ERC-20 and ERC-721 token transfers by default (sets `exactCalldata` to `0x`).
149
+
You can optionally configure `exactCalldata` to restrict transactions to a specific operation, or configure
150
+
`allowedCalldata` to allow transactions that match certain patterns or ranges.
145
151
146
-
Internally, this scope uses the [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) and [`nativeTokenPeriodTransfer`](../../../reference/delegation/caveats.md#nativetokenperiodtransfer) caveat enforcers.
152
+
Internally, this scope uses the [`nativeTokenPeriodTransfer`](../../../reference/delegation/caveats.md#nativetokenperiodtransfer) caveat enforcer, and
153
+
optionally uses the [`allowedCalldata`](../../../reference/delegation/caveats.md#allowedcalldata) or [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) caveat enforcers when those parameters are specified.
154
+
See the [native token periodic scope reference](../../../reference/delegation/delegation-scopes.md#native-token-periodic-scope) for more details.
@@ -172,9 +180,13 @@ Token transfers are blocked until the defined start timestamp.
172
180
At the start, a specified initial amount is released, after which tokens accrue linearly at the configured rate, up to the maximum allowed amount.
173
181
For example, Alice creates delegation that allows Bob to spend 0.001 ETH per second, starting with an initial amount of 0.01 ETH, up to a maximum of 0.1 ETH.
174
182
175
-
When this scope is applied, the toolkit disallows ERC-20 and ERC-721 token transfers by default, setting the allowed `calldata` to `0x`.
183
+
When this scope is applied, the toolkit disallows ERC-20 and ERC-721 token transfers by default (sets `exactCalldata` to `0x`).
184
+
You can optionally configure `exactCalldata` to restrict transactions to a specific operation, or configure
185
+
`allowedCalldata` to allow transactions that match certain patterns or ranges.
176
186
177
-
Internally, this scope uses the [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) and [`nativeTokenStreaming`](../../../reference/delegation/caveats.md#nativetokenstreaming) caveat enforcers.
187
+
Internally, this scope uses the [`nativeTokenStreaming`](../../../reference/delegation/caveats.md#nativetokenstreaming) caveat enforcer, and
188
+
optionally uses the [`allowedCalldata`](../../../reference/delegation/caveats.md#allowedcalldata) or [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) caveat enforcers when those parameters are specified.
189
+
See the [native token streaming scope reference](../../../reference/delegation/delegation-scopes.md#native-token-streaming-scope) for more details.
This scope ensures that native token transfers are limited to a predefined maximum amount.
203
-
This scope is useful for setting simple, fixed transfer limits without any timebased or streaming conditions.
215
+
This scope is useful for setting simple, fixed transfer limits without any time-based or streaming conditions.
204
216
For example, Alice creates a delegation that allows Bob to spend up to 0.1 ETH without any conditions.
205
217
Bob may use the 0.1 ETH in a single transaction or make multiple transactions, as long as the total does not exceed 0.1 ETH.
206
218
207
-
When this scope is applied, the toolkit disallows ERC-20 and ERC-721 token transfers by default, setting the allowed `calldata` to `0x`.
219
+
When this scope is applied, the toolkit disallows ERC-20 and ERC-721 token transfers by default (sets `exactCalldata` to `0x`).
220
+
You can optionally configure `exactCalldata` to restrict transactions to a specific operation, or configure
221
+
`allowedCalldata` to allow transactions that match certain patterns or ranges.
208
222
209
-
Internally, this scope uses the [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) and [`nativeTokenTransferAmount`](../../../reference/delegation/caveats.md#nativetokentransferamount) caveat enforcers.
223
+
Internally, this scope uses the [`nativeTokenTransferAmount`](../../../reference/delegation/caveats.md#nativetokentransferamount) caveat enforcer, and
224
+
optionally uses the [`allowedCalldata`](../../../reference/delegation/caveats.md#allowedcalldata) or [`exactCalldata`](../../../reference/delegation/caveats.md#exactcalldata) caveat enforcers when those parameters are specified.
225
+
See the [native token transfer scope reference](../../../reference/delegation/delegation-scopes.md#native-token-transfer-scope) for more details.
0 commit comments