This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.
defifundr_evm_contract/
├── contracts/ # Solidity contracts
│ └── Lock.sol
├── ignition/modules/ # Deployment modules
│ └── Lock.ts
├── scripts/ # Deployment scripts
├── test/ # Unit tests
│ └── Lock.ts
├── hardhat.config.ts # Hardhat configuration
├── package.json # Project metadata and scripts
└── README.md # Project documentation
- yarn
git clone https://github.com/DefiFundr-Labs/defifundr_stark_contract
cd defifundr_stark_contract
yarn
scarb build
scarb test
yarn deploy
- contracts/Lock.sol: Core contract demonstrating time-locked Ether storage.
- ignition/modules/Lock.ts: Hardhat Ignition script for deploying the contract.
- test/Lock.ts: Unit tests covering deployment and interaction logic.
- Contract is deployed using Hardhat Ignition.
- Functions are accessed via test scripts or front-end integration.
- Project configuration managed through
hardhat.config.ts
.
All Solidity contracts should include NatSpec comments.
Example:
/// @title Lock Contract
/// @notice Stores Ether until a specific unlock time
/// @dev Demonstrates Solidity time-lock pattern
- Tests are written in TypeScript using
chai
andethers.js
. - Focus on unit-level testing and gas efficiency.
- Ensure 100% coverage for all public functions.
Run tests with coverage:
npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts --network localhost
Coming soon: Configuration for testnets and mainnet.
- Use access control modifiers (
onlyOwner
). - Avoid hardcoding sensitive values.
- Include assertions and invariants.
- Conduct manual and automated audits.
To generate API documentation from Solidity contracts:
npm install --save-dev solidity-docgen
npx solidity-docgen
- Fork the repo and create a feature branch.
- Write clear, descriptive commit messages.
- Include relevant tests for any changes.
- Ensure documentation is updated.
- Open a pull request for review.
- Documentation should be updated with every code change.
- Use automation tools like
solidity-docgen
to maintain API docs. - New developers should be able to get started using this file alone.