A gas-efficient smart contract that allows users to register, update, view, and delete their personal data. Built with a strong focus on optimization, security, and clarity using Foundry for testing and development.
- Contract Name: OptimizedGasSaver
- Language: Solidity ^0.8.18
- Tooling: Foundry
- License: MIT
- Author: MichealKing (@BuildsWithKing)
- Test Coverage: 100%
| Feature | Description |
|---|---|
| Register | Users can register with first, middle, last name, and age |
| View Data | Users can retrieve their saved data |
| Update | Users can securely update their data |
| Delete | Users can permanently delete their account |
| Gas Optimization | Uses bytes32 over string for reduced gas consumption |
| Access Control | Only registered users can update or delete their own data |
- Framework: Foundry
- Total Coverage: 100%
- Functions Tested:
- register
- getMyData
- getUserData(Owner-only)
- update
- delete
Here's a screenshot of my terminal showing 100% test coverage.

forge test
forge coverage
forge script script/DeployOptimizedGasSaver.s.sol:DeployOptimizedGasSaver --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY -vvvvgassaverapp-with-foundry/
├── src/
│ └── OptimizedGasSaver.sol
├── test/
│ └── OptimizedGasSaverTest.t.sol
├── foundry.toml
├── README.md
- Gas optimization using bytes32 instead of string
- Secure and clean struct handling in mappings
- Advanced Foundry testing techniques and 100% test coverage
- Writing efficient, production-ready smart contracts with minimal gas usage
✅ Contract deployed and verified successfully on Sepolia Testnet.
Contract Address: 0x864e98EC84C6Ec0089DDfCF4266e2dcA0BdEF40a
Etherscan Link: View on Sepolia Etherscan
Here’s a snapshot of my terminal showing the successful deployment using Foundry:
Run locally using Foundry:
forge test
This project is licensed under the MIT License. Contributions and forks are welcome!
Built by MichealKing Solidity Developer | Builder | Creator of 30 Days of Solidity.
