PushGuard is a cross-chain wallet security application built on Push Chain that protects users from phishing, unlimited token approvals, and unexpected transfers across Ethereum, Solana, and Push Chain.
- Universal Wallet Protection: Works with any wallet across multiple chains
- Real-time Threat Detection: Monitors for suspicious activities
- Push Protocol Notifications: Instant alerts via Push Protocol
- Cross-chain Compatibility: Native support for Ethereum, Solana, and Push Chain
- No Chain Switching Required: Seamless experience using Push Chain's shared-state architecture
PushGuard leverages Push Chain's unique shared-state architecture:
- Universal Execution Accounts (UEAs): Automatically created for external-chain users
- Chain-aware Detection: Uses
UEAFactoryto identify user's origin chain - Per-chain Protection: Maintains separate guard status for each chain
- Push Notifications: Integrates with Push Protocol for real-time alerts
- Node.js >= 16.0.0
- npm or yarn
- A wallet (MetaMask, Phantom, etc.)
# Clone the repository
git clone <repository-url>
cd pushguard
# Install dependencies for smart contracts
cd contracts
npm install
# Install dependencies for frontend
cd ../frontend
npm install
# Start the frontend development server
cd frontend
npm run devVisit http://localhost:3000 to access the application.
- User opens the dApp and clicks "Connect Wallet"
- Chooses any supported wallet (MetaMask, Phantom, etc.)
- Push Chain automatically creates a Universal Execution Account (UEA) if needed
- User clicks "Enable PushGuard"
- Smart contract uses
UEAFactoryto detect the user's origin chain - Protection is activated for that specific chain
- Frontend monitors for suspicious activities (simulated in this demo)
- When detected, reports to the smart contract
- Smart contract emits threat detection events
- Frontend listens for events and sends Push Protocol notifications
- User receives real-time alerts
- Users can enable/disable protection for each chain independently
- View history of detected threats
pushguard/
βββ contracts/ # Solidity smart contracts
β βββ PushGuard.sol # Main contract
β βββ hardhat.config.js # Hardhat configuration
β βββ scripts/ # Deployment scripts
βββ frontend/ # Next.js frontend application
β βββ src/
β β βββ app/ # React components and pages
β β βββ lib/ # Utility functions and contract addresses
β βββ public/ # Static assets
βββ README.md
# Compile contracts
cd contracts
npx hardhat compile
# Deploy to Push Chain testnet
npx hardhat run scripts/deploy.js --network pushchain# Start development server
cd frontend
npm run dev
# Build for production
npm run build# Run smart contract tests
cd contracts
npx hardhat testPushGuard demonstrates proper integration with Push Chain's core features:
- UEAFactory Pattern: Correctly uses
getOriginForUEAto identify user's origin chain - Universal Wallet Kit: Implements
@pushchain/ui-kitfor seamless wallet connection - Cross-chain State Management: Maintains per-chain protection status
- Push Protocol Integration: Sends notifications using
@pushprotocol/restapi
- Connect Ethereum wallet
- Enable PushGuard protection
- Simulate a threat (high-value token approval)
- Receive instant Push notification
- Switch to Solana wallet
- Enable protection for Solana
- Simulate SPL token approval threat
- Receive notification for Solana threat
Visualize the architecture and user flow of PushGuard with Mermaid.js diagrams.
graph TD
A[User Opens dApp] --> B[Connect Wallet]
B --> C{Wallet Type?}
C -->|Push Chain| D[Direct Access]
C -->|External Chain| E[Auto-create UEA]
E --> F[Access via UEA]
D --> G[Enable PushGuard]
F --> G
G --> H{Toggle Protection}
H -->|On| I[Monitor Transactions]
H -->|Off| J[No Monitoring]
I --> K[Threat Detected]
K --> L[Report to Smart Contract]
L --> M[Emit ThreatDetected Event]
M --> N[Send Push Notification]
N --> O[User Receives Alert]
classDiagram
class PushGuard {
+mapping(bytes => bool) guardActive
+toggleGuard(bool enable)
+isGuardActive(string chainNamespace, string chainId) bool
+reportThreat(string threatType, string details)
}
class IUEAFactory {
<<interface>>
+getOriginForUEA(address addr) UniversalAccountId, bool
}
class UniversalAccountId {
+string chainNamespace
+string chainId
+bytes owner
}
class Events {
<<enumeration>>
GuardToggled(bool, address, string, string)
ThreatDetected(address, string, string, string, string)
}
PushGuard --> IUEAFactory : uses
PushGuard --> UniversalAccountId : uses
PushGuard --> Events : emits
Note: These diagrams are rendered using Mermaid.js. If you're viewing this on GitHub, the diagrams should display automatically. If you're using a Markdown viewer that doesn't support Mermaid.js, you may need to install a Mermaid plugin or view the diagrams on Mermaid Live Editor.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.