A fixed-term deposit smart contract where users can lock ETH for a set duration and automatically earn simple fixed interest upon maturity.
This smart contract simulates a traditional fixed(TradFi) deposit account using Ethereum.
Users deposit ETH for a fixed period. After the term expires, Chainlink Automation detects maturity and automatically triggers a payout of the principal + interest.
This project focuses on time-based automation, state transitions, and decentralized payout scheduling — no randomness, multi-user pooling, or external oracles beyond time and automation.
- ✅ Fixed-term locking – Users deposit ETH that remains locked for a predefined duration.
- 💰 Earn fixed interest – Upon maturity, users receive their deposit plus a simple fixed interest (funded from contract preload for simplicity).
- ⚙️ Chainlink Automation – Automatically calls the payout function when the term ends.
- ⏲️ Time-based logic – Uses
block.timestampfor duration tracking. - 🔒 State control – Transitions from
OPEN → LOCKED → PAYING_OUT. - 🧪 Fully testable – Includes Foundry tests with time manipulation (
vm.warp) and upkeep simulation.
-
Deposit ETH
- User calls
depositEth()with the required minimum deposit. - Contract locks and starts the fixed-term timer.
- User calls
-
Wait for Term Completion
- Contract tracks elapsed time using
block.timestamp. - During this period, ETH remains locked and cannot be withdrawn.
- Contract tracks elapsed time using
-
Chainlink Automation Check
- Chainlink Automation regularly calls
checkUpkeep()to see if the term has ended. - When maturity is reached,
performUpkeep()automatically triggers.
- Chainlink Automation regularly calls
-
Payout Execution
- Contract transitions to the
PAYING_OUTstate. - Payout function releases principal + fixed interest back to the depositor.
- Contract transitions to the
-
Reset or End
- Once payout completes, the contract resets and emits the completed fixed deposit.
| Parameter | Type | Description |
|---|---|---|
minimumDeposit |
uint256 |
The minimum eth deposit needed to enter the contract. |
termPeriod |
uint256 |
Duration (in seconds) of the fixed deposit term. |
- Contract is preloaded with 0.1 ETH to fund interest payments.
- Chainlink
AutomationRegistraris mocked locally for testing. - Foundry test suite uses:
vm.warp()to simulate time passingvm.deal()to assign ETH balancesvm.recordLogs()to assert Automation-triggered state changes
This project demonstrates:
- Automated smart contract execution (via Chainlink Automation)
- Deterministic time-based logic
- Secure payout mechanisms
- Strong test-driven smart contract development
- ✅ User deposits ETH → contract locks funds
- ⏳ Time passes beyond term → upkeep becomes true
- ⚙️ Chainlink Automation triggers payout
- 💸 Payout transfers principal + interest
- 🔁 Contract resets to allow future deposits