Wallet Balance Watcher — Drosera Trap SERGEANT
Create a functional and deployable Drosera trap that:
-
Monitors ETH balance anomalies of a specific wallet,
-
Uses the standard collect() / shouldRespond() interface,
-
Triggers a response when balance deviation exceeds a given threshold (1%),
-
Integrates with a separate alert contract to handle responses.
Ethereum wallets involved in DAO treasury, DeFi protocol management, or vesting operations must maintain a consistent balance. Any unexpected change — loss or gain — could indicate compromise, human error, or exploit.
Solution: Monitor ETH balance of a wallet across blocks. Trigger a response if there's a significant deviation in either direction.
Trap Contract: WalletBalanceWatcher.sol
Pay attention to this string "address public constant target = 0x006dFDD9F1645eAB33f46dCD69ff34640Aa05426; // change to your own wallet address"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface ITrap {
function collect() external view returns (bytes memory);
function shouldRespond(bytes[] calldata data) external pure returns (bool, bytes memory);
}
contract WalletBalanceWatcher is ITrap {
address public constant target = 0x006dFDD9F1645eAB33f46dCD69ff34640Aa05426; // change to your own wallet address
uint256 public constant thresholdPercent = 1;
function collect() external view override returns (bytes memory) {
return abi.encode(target.balance);
}
function shouldRespond(bytes[] calldata data) external pure override returns (bool, bytes memory) {
if (data.length < 2) return (false, "Insufficient data");
uint256 current = abi.decode(data[0], (uint256));
uint256 previous = abi.decode(data[1], (uint256));
uint256 diff = current > previous ? current - previous : previous - current;
uint256 percent = (diff * 100) / previous;
if (percent >= thresholdPercent) {
return (true, abi.encode("Balance anomaly detected"));
}
return (false, "");
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract SendEmergencyAlert {
event EmergencyTriggered(string message);
function handleAnomaly(string calldata message) external {
emit EmergencyTriggered(message);
}
}-
Detects suspicious ETH flows from monitored addresses,
-
Provides an automated alerting mechanism,
-
Can integrate with automation logic (e.g., freezing funds, emergency DAO alerts).
forge create src/WalletBalanceWatcher.sol:WalletBalanceWatcher \
--rpc-url https://ethereum-hoodi-rpc.publicnode.com \
--private-key 0x...forge create src/SendEmergencyAlert.sol:SendEmergencyAlert \
--rpc-url https://ethereum-hoodi-rpc.publicnode.com \
--private-key 0x...[traps.mytrap]
path = "out/WalletBalanceWatcher.sol/WalletBalanceWatcher.json"
response_contract = "<SendEmergencyAlert address>"
response_function = "handleAnomaly(string)"DROSERA_PRIVATE_KEY=0x... drosera apply-
Send ETH to/from target address on Ethereum Hoodi testnet.
-
Wait 1-3 blocks.
-
Observe logs from Drosera operator:
-
get ShouldRespond='true' in logs and Drosera dashboard
-
Allow dynamic threshold setting via setter,
-
Track ERC-20 balances in addition to native ETH,
-
Chain multiple traps using a unified collector.
First created: July 29, 2025
Discord: ironivanoff
Telegram: @aiivanoff