Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyGold (MGLD): Secure ERC-20 Infrastructure & DeFi Testbed

License Network Solidity

📖 Introduction

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.

🔗 Deployed Contracts (Sepolia Testnet)

Contract Address Verification
MGLD Token 0xb1995a38F04163A4E59536C74A2E3c12a85097eA ✅ Verified
Faucet 0xEcAa1791cb8282a58bA7F8c5cc49bA3feF204171 ✅ Verified
Uniswap Pool 0xb1995a38F04163A4E59536C74A2E3c12a85097eA (MGLD/ETH)

🛡️ Security Architecture

1. Incident Response System (Pausable)

To mitigate potential exploits (e.g., reentrancy or logic errors) post-deployment, the contract implements a Circuit Breaker pattern.

  • Mechanism: The whenNotPaused modifier 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.

2. Malicious Actor Isolation (Blacklist)

Implements compliance-ready access control to freeze assets held by compromised or malicious addresses.

  • Mechanism: beforeTokenTransfer hook checks a mapping(address => bool) isBlacklisted.
  • Use Case: Preventing hackers from cashing out stolen funds via DEXs.

3. Anti-Replay & UX (EIP-2612 Permit)

  • Mechanism: Uses secp256k1 signatures for off-chain approval.
  • Benefit: Prevents specific front-running vectors associated with approve() and enables gasless meta-transactions.

⚠️ Governance Analysis (Research Note)

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.

🛠️ Tech Stack & Tooling

  • Smart Contracts: Solidity 0.8.24
  • Framework: Hardhat + pnpm
  • Libraries: OpenZeppelin Contracts (v5.0)
  • DeFi Integration: Uniswap V3 SDK
  • Scripts: Ethers.js v6

🔗 Deployed Contracts (Sepolia Testnet)

Contract Address Status
MGLD Token (v2 - Secured) 0xb1995a38F04163A4E59536C74A2E3c12a85097eA ✅ Verified (Pausable, Permit active)

🚀 Quick Start

Deploy Contracts with Defense Mechanisms

# 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:sepolia

📄 License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages