A DAO treasurer manages multiple funding streams across Ethereum, Arbitrum, and Polygon. Different payment cycles require different approval thresholds, and the standard Safe Wallet interface, while secure, forces manual review of every transaction through the same visual flow. The treasurer needs a way to automate routine payments, enforce custom approval logic based on transaction type and amount, and integrate directly with internal accounting systems—without sacrificing the multisig security model that makes Safe a trusted choice for organizational treasuries in the first place.
This is where the Safe API becomes essential. Rather than treating the smart contract wallet as a black box accessed only through the official UI, developers can build custom workflows that programmatically create, simulate, execute, and monitor transactions. The API exposes Safe’s core capabilities—transaction queuing, signer management, threshold enforcement, and on-chain execution—to external applications, enabling orchestration patterns that the standard interface does not support. Understanding how to integrate with Safe’s infrastructure means moving beyond point-and-click transaction approval into systematic, auditable, and often automated approval pipelines that align with organizational governance needs.
The Safe API architecture and core responsibilities
Safe’s API is not a single endpoint but a collection of service layers, each handling a distinct responsibility in the transaction lifecycle. The transaction service manages the creation, queuing, and status tracking of pending transactions. The relay service broadcasts transactions to the blockchain using Safe’s infrastructure, removing the need for signers to hold native tokens for gas fees. The signer API facilitates the cryptographic signing process, coordinating which signers must approve a transaction and in what order. Understanding these layers is foundational because each one presents different integration points, different security assumptions, and different failure modes.
The transaction service is stateful and web-based, tracking Safe’s pending transactions in a database indexed by Safe address, chain ID, and nonce. When a transaction is created, it enters a queue with a unique hash and tracking identifier. Other signers can query this service to discover pending approvals, retrieve transaction details, and submit their signatures. The API returns transaction metadata including the target contract, function call data, ETH value, estimated gas, and accumulated signatures. This design allows external applications to poll for approval opportunities or to subscribe to webhooks that notify signers when action is needed.
The relay service handles the final broadcast to the blockchain. Because Safe transactions require gas fees and signature coordination, the relay layer abstracts away some operational friction: a sponsor can pay for gas, signers do not need ETH balance in their own accounts, and the transaction propagation is managed by Safe’s infrastructure rather than requiring individual broadcast attempts. However, this convenience introduces a dependency on Safe’s relay availability and fee model. Developers building high-volume or time-critical systems may need to implement fallback relay infrastructure or direct blockchain submission as an alternative.
The signer API bridges the gap between human approval workflows and on-chain execution. It standardizes how different signing methods—hardware wallets, browser extensions, key management services, and multisig contract signers—contribute their cryptographic commitments to a single transaction. By separating the signer API from the blockchain interaction, Safe allows signers to remain offline or disconnected until the moment their signature is required, reducing the window during which a signer’s credential could be compromised.
Building custom approval workflows with transaction creation and queuing
The canonical workflow is: create a transaction, collect signatures, submit to the blockchain. The Safe API allows this process to be fragmented, delayed, and conditional in ways that the UI does not easily support. For example, a payment automation system might create all expected transactions for a month upfront, then distribute them to signers on different schedules based on internal approval gates. A transaction created in the API does not automatically require immediate signing; it can exist in a pending state indefinitely, allowing organizational processes to govern when signatures are solicited.
Creating a transaction via the API requires a specific structure: the target contract address, the function call data (encoded according to the contract’s ABI), the value in ETH or tokens being transferred, the operation type (whether a CALL or DELEGATECALL), and a safe transaction gas estimate. The API validates these parameters against the Safe’s configuration—checking that the proposed transaction respects the current threshold, does not violate any guards or module restrictions, and is compatible with the Safe’s contract version. The response includes a transaction hash, a nonce that ensures ordering, and the signing requirements for that specific Safe.
The signature collection phase is where custom workflows diverge most from the standard UI. Rather than presenting a single “Confirm” button, an application can implement domain-specific logic: queuing transactions by category, applying different approval thresholds to different transaction types, or requiring signatures from specific signers for specific operations. A treasury application might require two signers for payments under $10,000 and three signers for larger amounts. A governance application might route transactions through a voting contract as an additional approval layer. The Safe API does not enforce these rules; it simply provides the transaction state and signature tracking infrastructure upon which applications build.
Querying pending transactions requires understanding the Safe’s nonce system. Each executed transaction increments the Safe’s nonce, and pending transactions are identified by their nonce value. A transaction with nonce 42 cannot be executed until all transactions with nonces 0 through 41 have been confirmed. This linear ordering is a security feature that prevents signature replay, but it also means that bottlenecks in the approval chain can block subsequent transactions. An automated system should monitor the nonce progression and flag approvals that are stalled.
Simulating transactions before execution to prevent irreversible mistakes
One of the most valuable and often underutilized API features is transaction simulation. Before submitting a transaction to the blockchain, an application can dry-run it against the current state of the Safe and its target contracts. This reveals whether the function call would succeed, what state changes would occur, how much gas would be consumed, and whether the Safe has sufficient token balances to execute the transfer. Simulation is a form of incident prevention: many irreversible mistakes—approving a malicious contract, sending tokens to a burn address, or misencoding function parameters—can be caught during simulation rather than after execution.
Simulation works by using the target blockchain’s eth_call or eth_simulate RPC method. The Safe transaction is constructed as though it were being executed, and the call runs against a copy of the blockchain state without actually modifying it. The response includes success or failure, return data, and detailed execution traces. An application can inspect the trace to verify that the intended state changes occurred. For example, before a token transfer, simulation can confirm that the Safe’s ERC-20 balance is sufficient and that the recipient contract will not revert upon receiving the tokens.
Advanced workflows use simulation to implement guardrails. A treasury system might simulate every transaction before presenting it for signatures, and automatically reject transactions that would violate spending limits, create problematic token concentrations, or interact with blacklisted contracts. The simulation output can also be displayed to signers as a form of structured verification: instead of asking signers to interpret raw function call data, the application shows the expected outcome. If simulation and reality diverge—a state change that was predicted in the simulation does not occur after execution—it indicates that blockchain conditions changed between simulation and broadcast, or that a front-running attack altered the outcome.
One caveat: simulation is accurate only for the blockchain state at the moment the simulation runs. In a live network, the state between simulation and execution can change due to other transactions being mined. Token prices fluctuate, contract state changes, and nonces advance. For transactions sensitive to state conditions, applications should re-simulate immediately before broadcast or implement slippage protections that revert the transaction if actual conditions differ from simulated predictions.
Integration patterns for DAOs and multi-chain treasury systems
DAOs and treasury-managing protocols use Safe as a dApp integration point. Rather than requiring DAO members to visit the official Safe UI, a DAO can embed transaction creation workflows directly into its governance dashboard. When a governance vote passes, the DAO’s smart contract can automatically create a Safe transaction representing the vote’s execution. The DAO’s frontend can then display this transaction, collect signatures from multisig signers (who may be individual contributors or council members), and broadcast it. This pattern centralizes transaction management within the organization’s own platforms while maintaining Safe’s multisig guarantees.
Multi-chain treasuries add complexity because a single DAO or protocol may operate Safes on Ethereum, Arbitrum, Optimism, Polygon, and other networks. Each chain has its own Safe contract, its own asset balances, and its own transaction queue. A centralized dashboard querying the Safe API can aggregate all pending transactions across all chains and present them to signers in a unified interface. However, this introduces a coordination problem: signatures collected for one chain cannot be reused on another. Applications must maintain separate transaction tracking, signature state, and broadcast queues for each chain.
The Safe’s support for contract signers—allowing another smart contract to serve as a signer rather than only individual accounts—enables layered governance. For example, a Safe on Ethereum might require signatures from token-holder multisigs on three separate chains. Each chain’s multisig approves transactions independently, and their combined approvals unlock the main Safe. This pattern allows organizations to distribute governance authority while maintaining a single point of control through the primary Safe. The trade-off is increased complexity: transactions require coordination across multiple chains and multiple governance layers.
API integrations should also account for Safe’s versioning. The current Safe implementation (1.3.0) differs in some ways from earlier versions, particularly in guard support and fee handling. Applications should query the Safe’s contract version and adjust their transaction creation logic accordingly. Using outdated transaction formats against a newer Safe, or vice versa, can cause silent failures or unexpected signature requirements.
Managing signers, roles, and permission hierarchies
A Safe Wallet’s security depends entirely on the control and distribution of signer keys. The API provides tools to query the current signer list, track signer roles, and understand the approval threshold. However, adding or removing signers requires a Safe transaction itself—changing the signer set must be approved by the existing signers according to the current threshold. This self-referential design prevents any single compromised signer or corrupted admin from unilaterally changing the wallet’s governance.
In sophisticated systems, signers take on different roles. One signer might be a hardware wallet held by a founder, another a multisig contract managed by a protocol, and another a cloud-based key management service with rate-limiting. The Safe API does not directly enforce role hierarchies, but applications built on top of Safe can. A treasury application can define policies such as “hardware-wallet signers can approve any transaction,” “cloud signers cannot approve transactions over $100,000,” or “at least one signer must be a hardware wallet.” These rules exist in the application logic, not in the Safe contract itself, but they provide organizational governance structure.
Signer key rotation presents an operational challenge that the API does not fully automate. Replacing a signer requires creating a transaction to remove the old signer and add a new one. During the interim period, the old signer can still approve new transactions. Applications managing high-security systems should implement signer rotation ceremonies: create the new-signer transaction, collect approvals, execute it, then conduct a grace period before the old signer’s credential is destroyed. The API can help track this process by monitoring the signer list before and after each transaction.
Monitoring, logging, and audit trails for compliance and incident response
Safe’s immutable on-chain transaction history is inherently auditable. Every executed transaction, its signers, its timestamp, and its effects are permanently recorded on the blockchain. However, applications often need to track transactions that are still pending, log who approved them and when, and correlate blockchain events with internal organizational records. The Safe API provides query endpoints that return transaction history, but applications should maintain their own audit logs that combine API data with additional context: the business reason for the transaction, the approver’s identity mapping, and the authorization gate that triggered creation.
Monitoring should focus on detecting anomalies that might indicate a compromised signer or unauthorized activity. Patterns to watch include: transactions created from unexpected sources, signers approving transactions outside their normal patterns, rapid-fire transactions that bypass the usual review cycle, and transactions queued for execution without corresponding approval flow. The API’s webhook support allows applications to subscribe to transaction state changes and respond programmatically. For example, if a transaction is created and approved by only one signer when the policy requires two, a monitoring system can alert administrators immediately.
Incident response procedures should account for Safe’s transaction queuing model. If a transaction is discovered to be malicious after signatures have been collected but before execution, it cannot be silently discarded; it remains in the queue and requires a separate cancellation transaction (typically created with a higher nonce) to supersede it. Documenting the cancellation process and preserving evidence that the original transaction was not executed is important for regulatory and compliance purposes. Applications should also implement transaction expiration policies: pending transactions older than a certain age should be reviewed or explicitly renewed.
Custom guard contracts and transaction filtering at execution time
Safe’s guard feature allows a custom smart contract to inspect every transaction before it executes, checking additional conditions or logging events. A guard contract can prevent execution if thresholds are violated, blacklisted contracts are being called, or state conditions are not met. Guards are an advanced feature that requires smart contract development expertise, but they represent the most powerful integration point between custom business logic and Safe’s execution model.
A typical guard contract checks three things: the transaction is not calling a dangerous function on a dangerous contract, transaction parameters fall within expected bounds, and the guard contract’s own state is consistent with the approval history. After these checks pass, the guard can emit an event (for audit logging) and allow Safe to continue execution. If any check fails, the guard contract reverts the entire transaction, preventing it from executing even if all signers approved it.
Guards introduce additional gas costs and execution complexity. Every transaction pays for the guard’s execution, and complex guard logic can make transactions expensive. Applications using guards should profile the gas cost impact and communicate it to users. Guards also become a potential security boundary: a buggy or compromised guard contract can block all transactions or allow dangerous operations. Guard contracts should be thoroughly tested, audited, and deployed on networks where governance can upgrade them if necessary.
One subtlety that often confuses developers: guards are checked at execution time, not at signature collection time. It is possible to collect all required signatures for a transaction and still have it blocked by the guard when broadcast to the blockchain. Applications integrating guards should re-simulate transactions immediately before broadcast to catch guard-related failures before they become visible on-chain failures.
Scaling and performance considerations for high-frequency transaction systems
Safe’s API is designed for systems managing dozens to thousands of transactions per day, but systems processing higher volumes need to account for indexing latency and relay congestion. The transaction service builds indexes based on blockchain events, which means there can be a delay (typically seconds to a few minutes on Ethereum) between a transaction being confirmed on-chain and appearing in API query results. High-frequency systems should maintain a local transaction cache, use blockchain event subscriptions (via tools like The Graph or Infura’s Streams) to stay ahead of API indexing, and not rely solely on API query results to determine whether a transaction has been executed.
The relay service, while convenient, has throughput limits. If an application queues thousands of transactions for execution simultaneously, the relay will process them sequentially, and some may queue for hours. For high-volume systems, direct blockchain submission using a private node or custom transaction broadcaster may be more reliable than relying on Safe’s relay. The trade-off is that direct submission requires gas management—ensuring that signers or a sponsor have sufficient balance to pay for execution.
Signature aggregation across many signers introduces parallelization benefits but also coordination overhead. Collecting signatures from ten signers in parallel is faster than collecting them sequentially, but coordinating their collection requires robust polling or webhook logic. Applications should implement timeouts for signature collection (if not all required signatures are collected within a reasonable period, alert the administrator) and track signer availability (if a signer consistently fails to provide signatures, flag them for review).
Rate-limiting and cost management are often overlooked. Safe’s relay and query services impose rate limits to prevent abuse. Applications should implement exponential backoff when hitting rate limits, cache query results where possible, and monitor their own API usage to avoid unexpected slowdowns. High-value transactions should be prioritized over routine transactions, and burst traffic should be smoothed rather than sent in sudden spikes.
Security best practices when building on Safe’s infrastructure
Building custom workflows on top of Safe does not eliminate Safe’s security model; it extends it. However, applications can introduce new vulnerabilities if they do not follow careful practices. First, all transaction creation should be logged and auditable. If an application allows any account to trigger transaction creation, implement strict access controls: only authorized addresses or accounts with specific permissions should create transactions. Second, never store private keys or seed phrases in the application itself. Use Safe’s signer API to delegate signing to hardware wallets, browser extensions, or remote signing services that maintain cryptographic isolation.
Third, verify transaction data before submission. Applications sometimes construct transaction parameters dynamically, pulling values from user input or external APIs. Always validate these parameters independently: confirm token addresses against a whitelist, verify amounts are within policy limits, and ensure function calls match their intended targets. A subtle mistake in address encoding or data serialization can cause a transaction to call a different function than intended, potentially draining funds.
Fourth, implement fail-safes for common mistakes. If your application allows users to trigger transactions, implement a confirmation step that displays the transaction in human-readable format and requires explicit approval before signing begins. Show the destination address, the amount, the contract being called, and any fees that will be incurred. Allow users to cancel after seeing this information but before any cryptographic operations occur.
Fifth, secure your API credentials. If your application uses Safe’s relay service or makes authenticated API calls, those credentials should be stored securely (in a key management service, environment variables, or a secrets manager) and rotated regularly. API credentials that leak can allow an attacker to create fake transactions or manipulate transaction status in your system. Consider whether your application truly needs full API access or whether read-only access is sufficient for your use case. You can review the full range of capabilities and security practices at the official Safe Wallet site, which publishes security advisories and best practices regularly.
Future directions and evolving integration patterns
Safe’s API and smart contract wallet are actively developed, and new features continue to emerge. Session keys, which allow temporary delegated signing authority for specific contracts and amounts, reduce friction for frequent interactions without requiring the full Safe transaction flow. Account abstraction integration makes Safe compatible with newer Ethereum standards, potentially enabling lighter-weight signers and more efficient transaction bundling. Cross-chain message passing protocols may eventually allow a single Safe transaction to coordinate multiple chains, simplifying the treasury management problem.
For developers building today, the important principle is to build modularly. Separate your application’s approval logic from the Safe integration layer, so that future Safe features or protocol changes can be adopted without rewriting business logic. Maintain clear transaction audit trails and logs. Test edge cases: what happens if a signer disappears, if blockchain conditions change between simulation and execution, or if the relay service is unavailable. These practices ensure that custom Safe integrations remain robust as the protocol and your organization’s needs evolve.
Frequently asked questions
Can I create Safe transactions programmatically without using the official UI?
Yes. Safe’s API provides endpoints to create transactions, specify signers, collect signatures, and broadcast to the blockchain. Your application can construct transactions in code, apply custom approval logic, and manage the full lifecycle. Transaction creation is standardized, but your application controls when signatures are requested and how approvals are orchestrated.
What happens if a pending transaction is discovered to be malicious?
Pending transactions cannot be silently deleted. A replacement transaction with a higher nonce must be created and executed to supersede the malicious one. Implement monitoring to catch suspicious transactions before all signatures are collected, and maintain clear audit logs showing which transactions were approved and which were cancelled.
How do I handle multiple Safe contracts across different blockchains?
Maintain separate transaction tracking and signature state for each Safe contract, indexed by chain ID. A centralized dashboard can aggregate pending transactions across all chains using the API, but signatures are chain-specific and cannot be reused. Coordinate approvals so that signers understand which chain a transaction targets before signing.
