Overview
Aggregations enable tracking and persistence of metric data from RPC requests over time. They allow policy rules to evaluate wallet activity against historical data, enabling more sophisticated controls like rate limiting and spending caps. Together with policies, aggregations make it possible to express constraints that depend on cumulative behavior rather than just the current request. This approach offers several benefits:- Rate limiting: Enforce transaction volume limits over time windows
- Spending caps: Limit total value transferred within a period
- Activity monitoring: Track transaction patterns across chain IDs or contract addresses
- Dynamic policies: Create rules that adapt based on historical wallet behavior
Concepts
Aggregations are defined by four core primitives: aggregations, metrics, windows, and group-by fields. At a high-level:- Aggregations define what data to track from RPC requests and how to aggregate it over time
- Metrics specify which field to extract from requests and how to aggregate values (e.g., sum transaction values)
- Windows define the time period over which to aggregate data (e.g., rolling 1-hour windows)
- Conditions define pre-filters that determine which requests should be included in the aggregation (e.g., only transactions to a specific contract)
- Group-by fields optionally partition aggregations by specific attributes (e.g., by chain ID or recipient)
reference field source. When a condition uses field_source: 'reference' and aggregation.{aggregation_id} as the field, the policy engine evaluates the current aggregated value against the specified threshold.
Create aggregations
Refer to the API reference for creating aggregations.Each app can have a maximum of 10 aggregations. Plan your aggregation strategy carefully to
stay within this limit.
How aggregations are applied
When a wallet receives an RPC request, aggregations are processed in two phases: data collection and policy evaluation.Data collection
When a request is made, all aggregations referenced in the wallet’s policies are updated. Multiple policies can reference the same aggregation, which is useful for sharing limits across different policy types (e.g., multiple signer override policies can reference the same aggregation to limit total transfer value out of a wallet in a rolling time window). This includes aggregations from:- The wallet’s directly assigned policy
- Owner policies (if the wallet has an owner)
- Signer override policies (if the request includes a signer with an override policy)
- The aggregation’s
conditionsare evaluated against the request. If all conditions pass, the aggregation proceeds to value extraction. - The metric value is extracted from the request based on the aggregation’s
metricconfiguration. - If the value cannot be extracted (e.g., the field doesn’t exist or the calldata doesn’t match the ABI), the value defaults to 0. Be careful when defining metrics: if you want the limit to apply to multiple operations (e.g., both
approve()andtransfer()calls against a contract ABI), you must configure separate aggregations or conditions for each operation. - The extracted value is added to the aggregation’s running total for the current time bucket.
Aggregation data is collected for all matching aggregations, regardless of whether the policy
ultimately allows or denies the request. This ensures accurate tracking even when requests are
denied for other reasons.
Policy evaluation
When evaluating a policy condition that references an aggregation:- The policy engine retrieves the current aggregated value for the time window.
- If group-by fields are configured, the engine uses the group key derived from the current request.
- If the metric value cannot be extracted from the current request, the policy engine uses the existing aggregated value (without including the current request).
- If the metric value can be extracted, the policy engine uses the aggregated value plus the current request’s value.
- The total is compared against the condition’s threshold using the specified operator.
Supported RPC methods
Aggregations can be configured for the following RPC methods:| Method | Chain | Description |
|---|---|---|
eth_signTransaction | Ethereum | Standard Ethereum transaction signing |
eth_signUserOperation | Ethereum | ERC-4337 user operation signing |
Metric configuration
Themetric object defines what value to extract from requests:
Supported field sources
| Field source | Description | Example fields |
|---|---|---|
'ethereum_transaction' | Direct transaction fields | value, chain_id |
'ethereum_calldata' | Decoded calldata fields (requires ABI) | function_name._amount, function_name._value |
Window configuration
Thewindow object defines the time bucketing strategy:
Conditions configuration
The optionalconditions array defines pre-filters that determine which requests should be included in the aggregation. Only requests that match all conditions will have their metric values aggregated.
Group-by configuration
The optionalgroup_by array partitions aggregations by specific fields:
When group-by fields are configured, separate aggregation buckets are maintained for each unique combination of group-by values.
