background image

 

35

 

 
Mathematical Libraries 
 
OpenZeppelin:  Due  to  Solidity's  native  limitations  in  performing  arithmetic  operations  securely, 
OpenZeppelin’s libraries were incorporated. The OpenZeppelin SafeMath library was used to prevent 
common errors like overflows and underflows during mathematical operations, ensuring the integrity 
of contract logic. 
 
Front-End Development 
 
React JS (v17.0.1): React JS was chosen for building the front-end interface for interacting with the 
deployed smart contracts. This framework provides a dynamic and modular approach to developing 
user interfaces, enabling seamless integration with Web3 libraries for blockchain interaction. It allows 
users  to  interact  with  contracts  deployed  on  the  Optimistic  Ethereum  network  in  a  user-friendly 
manner. 
 

5.2 Smart Contract Development 

 
The  development  of  our  smart  contracts  focuses  on  managing  energy  transactions  and  tracking 
renewable energy certificates using a decentralized, blockchain-based system. These smart contracts, 
written  in  Solidity,  facilitate  the  creation,  trading,  and  verification  of  VPPAs.  They  ensure 
transparency, traceability, and trust between energy producers (sellers) and buyers, while adhering to 
the principles of decentralization and security. They smart contracts were deployed on the Rinkeby 
test net and evaluated.  

5.2.1 Constraints and Conditions 

 
In our smart contract system for energy trading and PPA creation, various constraints and conditions 
govern how contracts are created, validated, and executed. These constraints are crucial for ensuring 
the  system's  integrity,  fairness,  and  compliance  with  energy  transaction  rules.  Below,  we  describe 
these rules mathematically, highlighting the logic behind energy trading and PPA creation. 
 
1. Contract Creation Constraints: 
 
For a contract cc, certain conditions must be met to ensure it is valid and executable. These conditions 
focus on the seller's available energy and the price per kilowatt-hour (kWh). 
Energy Availability  Constraint: The seller’s available energy  scsc  must be less than or equal to the 
amount of energy 

𝑒

𝑐

 offered in the PPA.  

𝑠

𝑐

≀   π‘’

𝑐

 

 
2. Price Constraint:  
 
The agreed price 

𝑝

𝑐

 in the contract must be greater than or equal to a minimum price 

𝑀𝑖𝑛_π‘ƒπ‘Ÿπ‘–π‘π‘’ set 

by the system. This ensures that all contracts respect a base market price and avoid exploitation.  
 

𝑝

𝑐

  β‰€  π‘€π‘–𝑛_π‘ƒπ‘Ÿπ‘–π‘π‘’ 

 
Together, these constraints ensure that sellers do not promise more energy than they can provide and 
that contracts maintain market price integrity. 
 
3. Energy Transaction Validation: