Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
LABS
Guides

How to Govern Transaction Execution Policies

A technical guide for developers on implementing and managing policies that control how transactions are executed, validated, and authorized on-chain.
Chainscore © 2026
introduction
SMART ACCOUNT GOVERNANCE

Introduction to Transaction Execution Policies

Transaction Execution Policies are programmable rules that define how a smart account can operate, enabling granular control over security, automation, and multi-party governance.

A Transaction Execution Policy (TEP) is a set of programmable rules that govern the execution of transactions from a smart contract account, often called a smart account. Unlike externally owned accounts (EOAs) controlled by a single private key, smart accounts use policies to define who can initiate transactions, what actions they can perform, when they can act, and how much they can spend. This transforms account security from a binary private key model into a flexible, rule-based system. Common policy types include spending limits, multi-signature requirements, time-locks, and allowlists for specific dApp interactions.

Policies are typically enforced by the account's entry point or a dedicated policy engine. When a user operation (the ERC-4337 standard for a bundled transaction) is submitted, the policy engine validates it against all active rules before execution. For example, a policy could mandate that any transfer over 1 ETH requires a 2-of-3 multi-signature approval, while smaller transfers can be executed by a single signer. This architecture separates the logic of "who can sign" from the logic of "what is allowed," enabling complex governance models without modifying the core account contract.

Implementing a basic spending limit policy demonstrates the concept. Below is a simplified Solidity example for an ERC-4337-compatible smart account using a policy module.

solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract SpendingLimitPolicy {
    mapping(address => uint256) public dailySpent;
    mapping(address => uint256) public dailyLimit;
    function validateTransaction(
        address sender,
        uint256 value,
        bytes calldata
    ) external returns (bool) {
        uint256 spentToday = dailySpent[sender];
        require(
            spentToday + value <= dailyLimit[sender],
            "Daily limit exceeded"
        );
        dailySpent[sender] = spentToday + value;
        return true;
    }
    // Function to reset daily counter (callable by a manager)
    function resetSpent(address _user) external {
        dailySpent[_user] = 0;
    }
}

The validateTransaction function is called by the account's entry point before execution, blocking transactions that exceed the limit.

Advanced use cases leverage policy composition and session keys. Policy composition allows multiple policies to be combined, such as requiring both a spending limit and a specific time window. Session keys are temporary signing keys granted limited authority by a policy, perfect for gaming or DeFi sessions where you want to approve a dApp for a set period and budget without exposing your main seed phrase. Projects like Safe{Wallet} (with its Zodiac modules), ZeroDev, and Biconomy offer SDKs and infrastructure to manage these policies, abstracting the complexity for developers.

Governance of these policies is critical. For a multi-signature Safe, adding or removing a policy is a multi-sig transaction itself. For more decentralized organizations, policy updates can be managed via a DAO vote using Snapshot and executed via a DAO module. This creates a hierarchical model: the DAO governs the high-level policy framework, while individual signers operate within those rules. Regular policy audits and simulations using tools like Tenderly or Foundry's forge are essential to ensure rules behave as intended and don't introduce vulnerabilities or lock funds.

prerequisites
GOVERNANCE

Prerequisites

Before implementing transaction execution policies, you need a foundational understanding of smart contract development, governance mechanisms, and the specific tools involved.

To govern transaction execution policies effectively, you must first understand the core components. This involves working with smart contracts that define the rules (the policy) and a governance framework that allows token holders or a multisig to modify these rules. You should be familiar with writing and deploying contracts on EVM-compatible chains like Ethereum, Arbitrum, or Polygon using development frameworks such as Hardhat or Foundry. A basic grasp of Solidity for the policy logic and JavaScript/TypeScript for interaction scripts is essential.

You will need access to and experience with specific governance tooling. For on-chain voting, platforms like OpenZeppelin Governor or Compound's Governor Bravo provide standard contracts to build upon. For off-chain signaling, familiarity with Snapshot is required. You must also understand how to manage private keys and sign transactions, whether through a CLI wallet, a library like ethers.js, or a service like Tenderly for simulating governance proposals before execution. Setting up a local testnet (e.g., with Hardhat) to prototype policies is highly recommended.

Finally, a clear definition of the policy's goal is a critical prerequisite. Are you restricting transaction types (e.g., no transfers to blacklisted addresses), setting gas limits, implementing timelocks, or requiring multi-signature approvals? You must map these requirements to concrete, testable logic within your smart contract. Document the intended behavior and failure modes. Without this clarity, creating a secure and effective governance-controlled policy is impossible, as the contract code must precisely encode the community's intent.

key-concepts-text
GOVERNANCE

Key Concepts: Execution Policies

Execution policies are programmable rules that define how a smart contract wallet or account can execute transactions, enabling granular control over security and automation.

An execution policy is a set of programmable rules attached to a smart account that governs transaction execution. Unlike traditional wallets where a single private key holds absolute authority, execution policies decentralize control by defining who can execute what actions, when, and under which conditions. This is a core component of Account Abstraction (AA) standards like ERC-4337, which separates the logic of transaction validation from the core protocol. Policies can enforce multi-signature requirements, spending limits, time locks, and interactions with specific smart contracts, turning a static keypair into a dynamic, rule-based entity.

Policies are typically implemented as separate smart contracts that the main account contract calls to validate a user operation. For example, a policy could require two out of three designated guardians to sign a transaction exceeding 1 ETH. Another common pattern is a session key policy, which grants a temporary, limited authority to a dApp for a specific set of actions, like performing swaps on a DEX for one hour. Developers define these policies using frameworks like the Safe{Core} Protocol or ZeroDev's Kernel, which provide modular building blocks for permission logic.

Setting up an execution policy involves deploying the policy contract and linking it to your account. Using a framework like Safe, you might interact with its ModuleManager to enable a policy module. A basic Solidity policy contract has a validateTransaction function that returns a boolean. For instance, a DailyLimitPolicy would check if the transaction value is below a daily cap stored in the contract's state. Failed validation reverts the entire user operation, preventing execution. This programmability allows for complex, non-custodial security models that are transparent and verifiable on-chain.

Execution policies enable several critical use cases in decentralized governance and institutional finance. Multi-signature vaults use them to require approvals from a committee. DeFi managers can implement policies that only allow interactions with pre-approved, audited protocol addresses to mitigate phishing. Recovery scenarios are also governed by policies, such as a social recovery module that activates after a 7-day timelock. By codifying rules directly into the account's operation flow, execution policies reduce reliance on off-chain processes and centralized intermediaries, enhancing both security and operational efficiency.

When designing policies, key considerations include gas efficiency (as validation runs on-chain), policy composability (stacking multiple rules), and upgradability. A poorly designed policy can create denial-of-service vectors or unintended restrictions. It's crucial to audit policy logic thoroughly. The ecosystem is evolving with standards like ERC-6900, which aims to modularize and standardize policy interfaces across different account abstraction implementations, promoting interoperability and safer development patterns for this foundational governance layer.

policy-components
GOVERNANCE PRIMER

Core Components of an Execution Policy

An execution policy is a programmable rule-set that defines how transactions are validated and executed. These components allow DAOs and multi-sig signers to enforce security, compliance, and operational logic.

03

Execution Constraints & Post-Checks

Rules that govern how the transaction executes and verify outcomes. This prevents unintended side-effects.

  • Receiver Constraints: Limit transactions to specific destination addresses (e.g., only official protocol treasuries).
  • Function Selectors: Allow only calls to specific smart contract functions (e.g., transfer(), but not approve()).
  • Slippage Tolerance: For DeFi actions, set a maximum acceptable slippage percentage on swaps.
  • State Validation: Confirm expected contract state changes after execution, reverting if conditions aren't met.
06

Monitoring & Incident Response

The tools and processes for observing policy enforcement and reacting to policy violations or emergencies.

  • Event Logging & Alerts: Use services like OpenZeppelin Defender or Tenderly to monitor for failed pre-checks or unauthorized proposals.
  • Emergency Scuttle Switch: A pre-defined policy component that can immediately freeze all transactions, often controlled by a distinct set of guardians.
  • Post-Mortem Analysis: Review transaction hashes and policy logs to understand why a transaction was blocked or approved, enabling iterative policy improvement.
COMPARISON

Tools for Managing Execution Policies

A comparison of popular tools and frameworks for defining and enforcing transaction execution policies on EVM chains.

FeatureOpenZeppelin DefenderSafe{Wallet} ModulesCustom Smart Contract

Primary Use Case

Managed security platform for operations

Multi-signature wallet governance

Bespoke protocol logic

Gas Abstraction

Relayer Network

Pre-built Policy Templates

Requires Off-Chain Service

Average Setup Time

1-2 hours

30-60 minutes

Days to weeks

Typical Monthly Cost (Team)

$100-500

$0 (gas only)

$0 (dev time)

Audit Requirement for Policies

Platform handles security

Module audit recommended

Full audit required

implementation-steps
IMPLEMENTATION STEPS

How to Govern Transaction Execution Policies

Transaction execution policies define the rules and constraints for how transactions are processed on a blockchain or within a smart contract system. This guide outlines the practical steps for implementing and managing these policies.

The first step is to define the policy's scope and objectives. Are you governing gas fees, transaction ordering, access control, or specific smart contract function calls? For example, a DAO treasury might implement a policy requiring multi-signature approval for any transfer exceeding 10 ETH. In a rollup, the policy could enforce a maximum transaction size of 120KB to optimize data availability costs. Clearly document the desired outcomes, such as reducing spam, enforcing compliance, or managing operational risk, before writing any code.

Next, implement the policy logic within smart contracts. Use function modifiers and access control patterns like OpenZeppelin's Ownable or AccessControl to enforce rules. For gas policies, you can use require(tx.gasprice <= maxGasPrice, "Gas price too high"). To manage execution flow, consider using a policy registry contract that holds the current rules, which other contracts query. A common pattern is the Policy Pattern, where a dedicated PolicyManager contract validates transactions against a set of rules before they are forwarded to the target contract via delegatecall or a similar mechanism.

For dynamic policies that need to change over time, you must implement a governance mechanism. This typically involves a governance token and a voting contract, such as a fork of Compound's Governor. Proposals to update policy parameters (e.g., changing a fee percentage or whitelisted address) are submitted, voted on by token holders, and, if passed, executed to update the policy contract's state. Ensure there is a timelock between a proposal's approval and its execution to give users time to react to changes. The OpenZeppelin Governor library provides a robust foundation for this.

Finally, monitor and analyze policy effectiveness. Use off-chain indexers or subgraphs to track metrics like transaction success/failure rates, average gas costs, and policy violation events. Tools like Tenderly or OpenZeppelin Defender can send alerts when a policy rule is triggered. Regularly review these metrics with your community or governance body. Policies are not set in stone; be prepared to iterate based on network conditions and user feedback, using the established governance process to propose and enact improvements.

TRANSACTION EXECUTION POLICIES

Code Examples and Patterns

Transaction execution policies define the rules and constraints for how transactions are processed. This section covers common implementation patterns, troubleshooting, and developer FAQs.

A transaction execution policy is a set of programmable rules that govern the conditions under which a transaction can be executed. It acts as a security and logic layer between a user's intent and the final on-chain state change. Policies can enforce constraints like:

  • Gas limits and fee management
  • Access control based on signer roles or token holdings
  • Time-based restrictions (e.g., valid only after a certain block)
  • Co-signer requirements for multi-party approvals
  • Destination whitelisting for contract interactions

In systems like Safe{Wallet} (with modules) or ERC-4337 Account Abstraction, policies are often implemented as separate smart contract modules that validate transactions before they are forwarded to the blockchain.

advanced-patterns
GOVERNANCE

Advanced Policy Patterns

Transaction execution policies define the rules for how user operations are processed and paid for. These patterns enable sophisticated use cases like sponsored transactions, session keys, and gas abstraction.

TRANSACTION EXECUTION POLICIES

Troubleshooting and Common Issues

Common developer questions and solutions for managing transaction execution policies, including policy creation, validation failures, and integration patterns.

Transaction policy validation fails when the submitted transaction violates a defined rule. Common causes include:

  • Insufficient Signatures: The transaction lacks the required number of signatures from the policy's designated signer set.
  • Expired Timelock: The transaction is submitted after the validAfter timestamp or before the validUntil timestamp defined in the policy.
  • Nonce Mismatch: The transaction uses a nonce that has already been executed or is out of sequence.
  • Rule Violation: The transaction's calldata, value, or destination address is blocked by a specific rule (e.g., a TargetSelectorRule or ValueRule).

To debug, inspect the policy's on-chain state and the transaction's parameters. Use the PolicyRegistry to check the active policy hash for your account and verify all conditions are met before submission.

TRANSACTION POLICIES

Frequently Asked Questions

Common questions and troubleshooting for developers implementing and managing transaction execution policies.

A transaction execution policy is a set of programmable rules that govern how transactions are processed by a relayer or sequencer before they are submitted on-chain. It acts as a middleware layer between a user's wallet and the blockchain.

How it works:

  1. A user signs a transaction intent.
  2. The signed intent is sent to a policy engine (e.g., Chainscore's Policy Engine).
  3. The engine evaluates the transaction against predefined rules (e.g., gas limits, allowed contracts, spending caps).
  4. If the transaction complies, it is forwarded for execution. If it violates a rule, it is blocked or requires additional approval.

This enables conditional execution, gas sponsorship, and security controls without modifying the underlying smart contracts.

conclusion
IMPLEMENTATION GUIDE

Conclusion and Next Steps

This guide has covered the core concepts of transaction execution policies. Here's a summary and a path forward for implementing and refining your own policies.

Transaction execution policies are a powerful tool for programmable security and gas optimization. By defining rules for gas limits, allowed contracts, spending caps, and transaction batching, you can create a tailored security model for your smart accounts or dApps. This moves beyond simple signature verification to enforce logic that protects user assets and streamlines operations. The key is to design policies that balance security with usability, preventing malicious actions without hindering legitimate use.

To implement a policy, start with a clear security model. Define what actions are permissible and what constitutes a risk. For example, a policy for a DeFi user might allow unlimited swaps on Uniswap and Aave but cap total daily withdrawals. Use the Policy interface from libraries like Safe{Core} Protocol or ZeroDev's Kernel to encode these rules. Your policy contract's validateUserOp function will be called by the account's EntryPoint to approve or reject each user operation before execution.

Here is a basic template for a time-lock policy that restricts transactions to specific hours:

solidity
contract TimeLockPolicy is IPolicy {
    uint256 public startHour;
    uint256 public endHour;

    constructor(uint256 _start, uint256 _end) {
        startHour = _start;
        endHour = _end;
    }

    function validateUserOp(
        UserOperation calldata userOp,
        bytes32 userOpHash,
        uint256
    ) external view override returns (bool) {
        uint256 hour = (block.timestamp / 3600) % 24;
        require(hour >= startHour && hour < endHour, "TimeLockPolicy: tx outside allowed window");
        return true;
    }
}

For next steps, explore policy composition. Complex rules are often built by combining smaller, modular policies using a PolicyManager or through ERC-7579 compliant modules. Test your policies thoroughly on a testnet like Sepolia using frameworks like Foundry or Hardhat. Simulate attack vectors to ensure your logic is robust. Finally, consider gas implications; complex validation can increase gas costs for users, so profile and optimize your policy's validateUserOp function.

The ecosystem for transaction policies is rapidly evolving. Stay updated by following the ERC-4337 account abstraction standards, the Safe{Core} Protocol documentation at docs.safe.global, and projects like ZeroDev, Biconomy, and Alchemy's Account Kit. Experiment with different policy types—from social recovery and session keys to spend limits and contract allowlists—to build more secure and user-friendly Web3 applications.