## 5 Working Operation of Blockchain in Smart Grid (SG)  
The integration of blockchain into the SG allows the energy players (producers, consumers, and prosumers) to maintain transactions in the decentralized system through mutual consensus and trust, as depicted in Figure 5. The various stages of the energy transaction are outlined below:  
**Step-1:** Different private sector energy sources (both green and conventional fossil-fuel-based) contact decentralized cloud-based energy auction services advertising their energy capacity with digital signature proof. **Step-2:** The decentralized cloud-based energy continuous double auction (CDA) updates the current energy costings based on the continuous change in supply and demand equations. It also matches buyers and sellers with each other. **Step-3:** After the buyer and seller commit to an energy deal at specified prices and other terms and conditions, the transaction agreements will be digitally verified by both the buyer and seller before an official transaction record is created to be authenticated and verified by the decentralized blockchain network. **Step-4:** Transactions are performed through fungible energy and BTC tokens being assigned to the energy seller and buyer, respectively. The decentralized blockchain network will verify these transactions through a cryptographic puzzle-based nonce generation to authenticate the sub-transaction happening on the SG network. The nonce is difficult to compute, requiring significant computing resources to provide evidence of PoW, but it is very easy to verify by other nodes on the blockchain network. **Step-5:** The blockchain and smart contracts will store the transaction history in the blockchain using DLT and securely distribute it to all nodes through specialized broadcast mechanisms. The blockchain ensures the immutability of smart contracts and transaction data by preventing records from being modified or deleted. Smart contracts will guarantee the completion of transactions between generators and consumers, providing assurance that producers will always deliver the electricity once a consumer has made the required payment. **Step-6:** Energy transfer starts/continues between the distributed energy source and the transmission line. Smart meters continuously log the amount of energy injected into the system from the seller. **Step-7:** The smart contract-based automated computer program in the cloud-based auction service will automatically keep the update of energy transfer from seller and buyer  
Figure 5: SG Operation in which multiple energy providers can negotiate energy deals and transfer power over the grid. financial tokens and again publish these transactions after cryptographic verification to the blockchain network to avoid problems such as duplicate spending. **Step-8:** The smart contract-based automated computer program will also maintain a record of FT (debit/credit) to update account management in the decentralized energy auction trading. Steps 4-8 will be continually performed until energy transfers received by the cloud-based auction service have been successfully terminated and no new requests have been received. The above blockchain-based SG framework provides immutability and traceability, which is good for auditing or solving a transaction dispute. The authentication and immutability aspect of the blockchain, e.g., the Ethereum blockchain [97], runs on the PoW consensus mechanism. In this mechanism, blocks of transactions are verified by miners around the world in exchange for a reward (e.g., BTCs). How blockchain can prevent a fraudulent transaction is depicted in Figure 6. Seller Sx initially has 100 energy units, and Buyer Bx has 500 BTC tokens. The seller, Sx, agrees to sell 10 energy units to Buyer Bx, which will cost 100 BTC tokens.