Context-awareness is very essential for blockchain-based IoT systems to guarantee successful system operations, even in presence of frequent external environment changes. However, current blockchain-based IoT solutions lack the adaptive ability required to accommodate external environment context changes during the system runtime. In this paper, we propose a context-aware smart contract system using rule-based reasoning for efficient energy consumption and environmental sustainability in blockchain-based IoT systems. Using smart contracts, the system collects contextual information, analyzes it by considering suitable control rules to perform required actions. To guarantee data authenticity and integrity, all transaction history and logs are stored in the blockchain-based distributed ledger for immutable data provenance evidence, accountability, and traceability. A smart grid home area network-based prototype was implemented on top of the Quorum blockchain to prove the feasibility of our concept. Besides, the performance evaluation of the experimental results shows that our system efficiently reduced energy consumption while maintaining environmental sustainability.