Automation Layer — Events
This page lists the on-chain events emitted by the Automation Layer and how to consume them from apps/indexers.
Heads up: Builders do not need to read these events to integrate automation (the
idyou pass is echoed back to your contract duringcheckSimpleAutomation/simpleAutomation). Events are useful for dashboards, analytics, notifications, and audits.
Event Reference
AccountCreated
Emitted when a contract registers a new automated account with createAccount(id).
event AccountCreated(address indexed customer);
customer— the calling contract address that registered the account.- ⚠️ Does not include the internal
accountNumberor yourid.- If you need to identify the new internal
accountNumber, callgetAccountsByAddress(customer)and compare before/after. - Most builders don’t need this number; keep using your own
idfor routing inside your contract.
- If you need to identify the new internal
AccountCancelled
Emitted when the registering contract calls cancelAccount(id).
event AccountCancelled(uint256 indexed index, address indexed account);
index— internalaccountNumberused by the Automation Layer.account— the registering contract address.- Notes:
- On cancel, the Automation Layer refunds the stored account creation fee (in the current fee token) from the owner to the registering contract.
- The owner must have granted allowance to the Automation Layer for refunds to succeed.
TransactionSuccess
Emitted when a node successfully executes automation for an account via simpleAutomation(accountNumber).
event TransactionSuccess(uint256 indexed index);
index— internalaccountNumber.- Semantics:
- This event is emitted before the Automation Layer calls your contract’s
simpleAutomation(id)and charges the fee;
however, if anything later in the transaction reverts, the event is rolled back and will not appear in logs. - Therefore, observing
TransactionSuccessin the logs implies the entire automation transaction succeeded (your action ran and the fee was paid).
- This event is emitted before the Automation Layer calls your contract’s
Consuming Events (ethers v6)
import { ethers } from "ethers";
// 1) Minimal ABI for events you care about
const automationAbi = [
"event AccountCreated(address indexed customer)",
"event AccountCancelled(uint256 indexed index, address indexed account)",
"event TransactionSuccess(uint256 indexed index)",
];
// 2) Connect to the Automation Layer on your network
const automation = new ethers.Contract(
/* AUTOMATION_LAYER_ADDRESS */,
automationAbi,
/* provider or signer */
);
// AccountCreated: show which contract registered
automation.on("AccountCreated", (customer, ev) => {
console.log("AccountCreated by:", customer, "tx:", ev.transactionHash);
});
// AccountCancelled: map internal accountNumber -> contract address
automation.on("AccountCancelled", (index, account, ev) => {
console.log("AccountCancelled:", index.toString(), "by:", account, "tx:", ev.transactionHash);
});
// TransactionSuccess: a successful automated run
automation.on("TransactionSuccess", (index, ev) => {
console.log("TransactionSuccess for accountNumber:", index.toString(), "tx:", ev.transactionHash);
});
Filtering by address or block range
const from = /* start block */;
const to = /* end block */;
// Query past events
const txSuccessFilter = automation.filters.TransactionSuccess();
const logs = await automation.queryFilter(txSuccessFilter, from, to);
logs.forEach((log) => console.log("Success index:", log.args.index.toString()));
When to Listen
- Dashboards & UX: Show recent automation activity (using
TransactionSuccess) for a given builder contract. - Alerts: Notify when an account is canceled (
AccountCancelled) or when expected runs are missing. - Ops & Analytics: Track adoption by counting
AccountCreatedover time per network.
Tips & Caveats
- You don’t need events to drive your contract logic. Your own
idflows through the automation hooks you implement:checkSimpleAutomation(id)andsimpleAutomation(id)receive the sameidyou registered withcreateAccount(id).
- Internal
accountNumbervs yourid:- The Automation Layer uses an internal
accountNumberfor bookkeeping and node calls. - Your contract never needs to know that
accountNumber; keep your ownidmapping.
- The Automation Layer uses an internal
- Indexing at scale:
- Consider using The Graph or similar to index events across networks, keyed by
account(the builder contract) andindex(internal account number).
- Consider using The Graph or similar to index events across networks, keyed by
- Refund path on cancel:
AccountCancelledindicates a logical cancel. If you’re tracking fee balances, remember the refund transfers from owner → account in the fee token.
See Also
- Automation Layer — Overview: Big picture, fee model, and use cases.
- Automation Layer — Core Functions: Exact function signatures, approvals, and examples.
- Networks (coming next): Per-chain Automation Layer & fee token addresses.