This project is an affiliated outcome of the course
CSIT5760 (L1) - Blockchain and Smart Contracts
at The Hong Kong University of Science and Technology (HKUST).
It is submitted as one of the assignments (individual project) of the course.
| Name | Role |
|---|---|
| Pritom Rajkhowa | Instructor & Teaching Assistant |
- Happy coding and smooth deployments 🚀
- Welcome to use this project
- According to the spirit of communism and open source, it is glad to share this project openly
- Hope you stay healthy, successful, and happy
- Hope your code always compiles, tests always pass, and deployments always succeed
- Concise bullet-point style, instead of long report/essay style
- No long essays or walls of text
- Each line short and direct
- Information modular and easy to scan
- Designed for developers and people here to quickly find what they need
- Install dependencies:
forge install foundry-rs/forge-std forge install OpenZeppelin/openzeppelin-contracts
- Build contracts:
forge build
- Run tests:
forge test -vvvv
- Smart contract system simulating library operations
- Components: LibrarySystem, MemberManagement, BookManagement, PointManagement
- Uses OpenZeppelin libraries and Foundry framework
- Foundry
- Python 3.8+
- Slither
- forge-std
- openzeppelin-contracts
- Run all tests:
forge test -vvvv - Save logs:
python3 script/shellScript/testAllGenerateLogTxt.py - Logs saved under
./log/forgeTest/
- Set environment variables:
SEPOLIA_RPC_URLPRIVATE_KEYETHERSCAN_API_KEY
- Run script:
bash ./script/deploymentScript/build_and_upload_to_testnet.sh
- Logs:
./broadcast/DeployAll.s.sol/.../run-latest.json./script/deployment_logs.txt
This section shows the deployed contract addresses on the Sepolia testnet, with direct Etherscan verification links.
| Contract | Address | Etherscan Link |
|---|---|---|
| BookManagement | 0xc4d275FBB516FC2EE67892F1B515B6574b08a739 |
View |
| MemberManagement | 0x6Cd93eF5B840E4aEA96e32483F4369591FF96484 |
View |
| PointManagement | 0xb38Ef4a91eBABf3aCE3c96EBE666dA7B78e0F14c |
View |
| LibrarySystem | 0xF9268383D2E16DA5cb5d9e2928A02f363EFC449e |
View |
src/Contract/→ contractssrc/Interface/→ interfacessrc/Library/→ shared librariestest/→ testsscript/→ deployment scriptslog/→ logs [Not Created/Included in repo]
.
├── .github/
│ └── workflows/
│ └── test.yml
├── .gitignore
├── README.md
├── README.zh-CN.md
├── foundry.lock
├── foundry.toml
├── script/
│ ├── deploymentScript/
│ │ ├── DeployAll.s.sol
│ │ └── build_and_upload_to_testnet.sh
│ └── shellScript/
│ ├── slitherAllGenerateLogTxt.py
│ ├── testAllGenerateLogTxt.py
│ └── testAllGenerateLogTxt.xonsh
├── slither.config.json
├── src/
│ ├── Contract/
│ │ ├── BookManagement.sol
│ │ ├── LibrarySystem.sol
│ │ ├── MemberManagement.sol
│ │ └── PointManagement.sol
│ ├── Interface/
│ │ ├── IBookManagement.sol
│ │ ├── ILibrarySystem.sol
│ │ ├── IMemberManagement.sol
│ │ └── IPointManagement.sol
│ └── Library/
│ ├── CombinedChildContract.sol
│ └── StructSummary.sol
├── test/
│ ├── BookManagement.t.sol
│ ├── LibrarySystem.t.sol
│ ├── MemberManagement.t.sol
│ └── PointManagement.t.sol
├── .gitmodules
└── lib/
├── forge-std/
└── openzeppelin-contracts/
- Child contracts restricted via
mainContract - Admin addresses for initialization and upgrades
- Install:
pip install slither-analyzer - Run:
python3 script/shellScript/slitherAllGenerateLogTxt.py - Logs in
./log/slither/
librarySystem.registerMember("Alice");
librarySystem.borrowBook(1);
librarySystem.addPoints("Alice", 10);
librarySystem.redeemPoints("Alice", 5);- GitHub Actions workflow runs tests on push
- Logs available in GitHub Actions and locally
- Test results →
./log/forgeTest/ - Security analysis →
./log/slither/ - Deployment issues → check RPC, gas, Foundry
- Solidity
^0.8.20(contracts use0.8.30) - OpenZeppelin
v5.x
- Pull requests welcome
- For major changes, open an issue first
- MIT License