Checkmate-Journal Hashing is a Solidity smart contract that allows users to securely store and manage hashes of their journal entries on the Ethereum blockchain. Each user can add new journal hashes, retrieve all their stored hashes, and check the total number of hashes they have submitted. This system provides integrity and traceability for journal data, ensuring that entries are tamper-proof and verifiable without revealing the actual content of the journals.
Checkmate Journal Hashing is a smart contract project designed to securely store and manage journal entry hashes on the Ethereum blockchain. Each user can add their own journal hashes, retrieve all their hashes, and check the count of their entries. This ensures integrity and traceability for journal data without exposing the actual content.
- Contract Name: JournalHash
- Main Features:
- Add a journal hash for the sender
- Retrieve all journal hashes for any user
- Get the count of journal hashes for any user
- Security:
- Only the sender can add their own hashes
- All hashes are public (anyone can read them)
Hardhat is a development environment for Ethereum smart contracts. It provides tools for compiling, deploying, testing, and debugging contracts. Key features include:
- Local test network (Hardhat Network)
- TypeScript/JavaScript support
- Plugin ecosystem (TypeChain, solidity-coverage, etc.)
- Easy integration with ethers.js
-
pnpm add --dev hardhat
Installs Hardhat as a development dependency using pnpm. -
npx hardhat init
Initializes a new Hardhat project with sample files and configuration. -
npx hardhat compile
Compiles all smart contracts in thecontracts/directory and generates artifacts. -
npx hardhat test
Runs all tests in thetest/directory using Mocha and Chai. -
npx hardhat node
Starts a local Ethereum test network for development and testing. -
npx hardhat run scripts/deploy.ts --network localhost
Runs the deployment script on the specified network (e.g., local Hardhat node). -
npx hardhat coverage
Generates a test coverage report for your smart contracts. -
npx hardhat console
Opens an interactive console to interact with your contracts and network.
All contract functions are covered by automated tests using Hardhat, Mocha, and Chai. Tests are located in the test/JournalHash.ts file.
npx hardhat test
- addJournalHash
npx hardhat test --grep "should add a journal hash for the sender" - getJournalHashes
npx hardhat test --grep "should return all journal hashes for a user" - getJournalHashCount
npx hardhat test --grep "should return the correct count of journal hashes" - Different users
npx hardhat test --grep "should allow different users to store their own hashes"
To see the percentage of code covered by tests:
npx hardhat coverage
contracts/ # Solidity smart contracts
artifacts/ # Compiled contract artifacts
cache/ # Hardhat cache files
test/ # Test files (TypeScript/JavaScript)
typechain-types/ # TypeChain generated types
scripts/ # Deployment and interaction scripts
hardhat.config.ts # Hardhat configuration
.env # Environment variables (not committed)
node_modules/
pnpm-lock.yaml
artifacts/
cache/
typechain-types/
.env
.DS_Store
Thumbs.db
.vscode/
.idea/
coverage/
*.log
build-info/
- Clone the repository
- Install dependencies:
pnpm install - Compile contracts:
npx hardhat compile - Run tests:
npx hardhat test - Check coverage:
npx hardhat coverage
For questions or contributions, feel free to open an issue or pull request.