MyGold is a security-hardened ERC-20 implementation designed to explore smart contract defense patterns and DeFi interoperability. Unlike standard token templates, this project focuses on integrating "Layer-1" security mechanisms including Circuit Breakers (Pausable), Access Control (Blacklists), and Gas-efficient Approvals (EIP-2612).
This repository serves as a practical implementation for my research into Blockchain Security, specifically analyzing the trade-offs between centralized administration and decentralized protocol safety.
| Contract | Address | Verification |
|---|---|---|
| MGLD Token | 0xb1995a38F04163A4E59536C74A2E3c12a85097eA |
✅ Verified |
| Faucet | 0xEcAa1791cb8282a58bA7F8c5cc49bA3feF204171 |
✅ Verified |
| Uniswap Pool | 0xb1995a38F04163A4E59536C74A2E3c12a85097eA |
(MGLD/ETH) |
To mitigate potential exploits (e.g., reentrancy or logic errors) post-deployment, the contract implements a Circuit Breaker pattern.
- Mechanism: The
whenNotPausedmodifier guards all token transfer functions (transfer,transferFrom,mint). - Use Case: In the event of a detected anomaly, the administrator can freeze all asset movements instantly.
Implements compliance-ready access control to freeze assets held by compromised or malicious addresses.
- Mechanism:
beforeTokenTransferhook checks amapping(address => bool) isBlacklisted. - Use Case: Preventing hackers from cashing out stolen funds via DEXs.
- Mechanism: Uses secp256k1 signatures for off-chain approval.
- Benefit: Prevents specific front-running vectors associated with
approve()and enables gasless meta-transactions.
Current Limitation: The project currently relies on the Ownable pattern (onlyOwner) for executing defense mechanisms.
- Security Risk: This creates a Centralized Point of Failure. Key leakage leads to total protocol compromise.
- Future Work: I am researching the integration of Distributed TEE Clusters (inspired by SolSaviour) to replace the single admin key with a democratic, privacy-preserving voting mechanism for contract destruction or patching.
- Smart Contracts: Solidity 0.8.24
- Framework: Hardhat + pnpm
- Libraries: OpenZeppelin Contracts (v5.0)
- DeFi Integration: Uniswap V3 SDK
- Scripts: Ethers.js v6
| Contract | Address | Status |
|---|---|---|
| MGLD Token (v2 - Secured) | 0xb1995a38F04163A4E59536C74A2E3c12a85097eA |
✅ Verified (Pausable, Permit active) |
# 1. Compile contracts
pnpm run compile
# 2. Configure environment variables (create .env file)
PRIVATE_KEY=your_private_key
SEPOLIA_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
# 3. Deploy to Sepolia testnet
pnpm run deploy:sepoliaMIT