This project is an advanced security-focused Solidity smart contract built with Hardhat, Ethers v6, and OpenZeppelin. It expands on the Ownable Tip Jar project by using role-based access control (RBAC) to manage multiple subsystems securely.
The goal of this contract is to simulate a real Web3 security architecture with:
- Granular multi-role permissions (Admin, Pauser, Blacklister, Freezer, Funder)
- A global emergency pause system
- Blacklist & freeze restrictions
- Reentrancy-safe withdrawals
- Tip storage with event logging
- Full Hardhat + Ethers v6 test suite
All tests pass successfully (41 passing, 0 failing).
Unlike Ownable, AccessControl supports flexible permissions. Roles used:
DEFAULT_ADMIN_ROLE– manages all rolesPAUSER_ROLE– pause/unpause the contractBLACKLISTER_ROLE– restrict malicious accountsFREEZER_ROLE– freeze accounts temporarilyFUNDER_ROLE– withdraws contract balance
whenNotPaused blocks sensitive functions. Only users with PAUSER_ROLE can trigger pause/unpause.
Custom modifiers:
notBlacklisted(account)notFrozen(account)
These restrict a user's ability to:
- send tips
- withdraw
- send ETH directly
Withdrawals use nonReentrant and .call{value: ...}() for safety.
Tests cover:
- Role assignment
- Unauthorized access reverts
- Pausing behavior
- Blacklist system
- Freeze system
- Tip storage (sendTip/receive/fallback)
- Reentrancy protection
- Withdraw logic
- Send ETH tips with messages
- Direct ETH support (receive/fallback)
- Retrieve all tips
- Fully permissioned role-based admin system
- Pausable contract state
- Blacklist + freeze functionality
- Secure withdrawals
- ReentrancyGuard protection
contracts/
SecurityAccessControl.sol
scripts/
deploy.js
interact.js
test/
AccessControlSecurity.test.js
hardhat.config.js
npx hardhat node
npx hardhat test
npx hardhat run scripts/deploy.js --network localhost
Examples:
node scripts/interact.js sendTip "Hello world" 0.1
node scripts/interact.js pause
node scripts/interact.js blacklist <address>
node scripts/interact.js balance
node scripts/interact.js withdraw
This project represents a major step into enterprise-style Solidity engineering. It demonstrates layered security, permissions architecture, and a full professional workflow from testing → deployment → contract interaction.