Skip to content

devansh-srv/Carbon-Credit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain based Carbon Credits (Sepolia)

A carbon credit trading platform leveraging React, Flask, and Solidity to promote transparency andaccountability in CSR activities which are main disadvantages of traditional carbon trading.

Idea: Allow companies and corporations to reduce thier net carbon emissions by financially helping NGO that help reduce carbon emissions by buying smart contract based Carbon Tokens from them.

  • Reduce problems like double spending, ambiguous credit generation, curruption that plague the traditional carbon credits system
  • Implemented a royality system which ensure that 10% of every transaction is given back to NGOs to unsure continues
  • A web app that simulates a blockchain carbon marketplace deployed on sepolia

Deployment

The test web app deplyed here
The contract deployed at address 0x5E5D1D1Dc0EDDB4f9e9E05FD872642Cd78F6eF51 on Sepolia view it on EtherScan

To get started use test credentials:

  • username: test_buyer
  • password: sepolia (You will require Sepolia account to use credits) Or ssee the demo here.

Introduction and Motivation

In India under section 135 of the Companies Act (2013), corporations must spend 2% of their average net profit from the preceding three years on Corporate Social Responsibility (CSR). However, many companies resort to "greenwashing" rather than making genuine societal contributions. Simultaneously, NGOs face inadequate funding, limiting their ability to execute impactful projects.

A decentralized Carbon Credit system leveraging blockchain can address these challenges. It ensures timely funding for NGOs, promotes transparency and accountability in CSR activities, and aligns corporate efforts with genuine societal and environmental betterment.

History

Carbon trading originated in the 1990s as a market-based solution to combat climate change, starting with the Kyoto Protocol in 1997, which introduced emissions trading among countries. It later evolved into voluntary markets and cap-and-trade systems, allowing companies to trade carbon credits globally.

Workflow

  1. NGOs will register on the platform and create Carbon Credits based on thier projects which will then be put up for sale.

  2. Companies or traders can buy these can buy these credits from the NGO and resell them further if they wish to.

    • For every resell of a carbon credit, 10% of the transaction value is returned to the original creator of the credit (NGO).
    • This mechanism ensures continuous funding support for the NGO's environmental projects.
  3. Credits must be available for finite amount of time to prevent double spending, once the project is completed the credits will be expired and can’t be sold further.

  4. Once the NGO completes the promised project, it can expire all credits associated with that project.

    • Once the NGO completes the promised project, it can expire all credits associated with that project.
    • The web app generates a certificate verifying the credit purchase and acknowledging the person’s contribution to offsetting specific amount of carbon.

Workflow Diagram:

Flow diagram

Sequence Diagram:

Sequence diagram (1)

Demo

DemoCarbonCredits.mp4

Tech Stack

Smart Contract:

Language: Solidity
Testing and Deployment: Hardhat

Image 1 Image 2

Front-end:

Framework: ReactJS
libraries: EthersJS

Image 1 Image 1

Back-end:

Framework: Python-Flask
Database: PostgreSQL

Image 1 Image 1

Setup & Installation

If you want to create your own smart contract

Smart Contract:

  1. Installing hardhat: Learn more about about hardhhat and for troubleshooting check here Go to SmartContracts folder

    npm install --save-dev hardhat
    
  2. Create a .env file and add: (will be required if you want to deploy on Sepolia otherwise remove sepolia from smartContracts\hardhta.config.js)

    TESTNET_URL=<YOUR_ALCHEMY_OR_INFURA_URL>
    PRIVATE_KEY=<YOUR_METAMASK_PRIVATE_KEY>
    

    To get alchemy/infura url go to Alechmy or Infura To get private key Metamask -> account details -> show private key (it will be preffered to use spare account for this)

  3. Compile contract:

    npx hardhat compile
    
  4. Test contract:

    npx hardhat test
    
  5. To Run local node:

    npx hardhat node
    

    then

    npx hardhat ignition deploy ./ignition/modules/cc.js --network localhost
    
  6. Setup local network in metamask:

    • Go to metamask
    • Press the network button (to the top left)
    • Add custom network
    • Write your network name
    • In RPC url add http://127.0.0.1:8545/ (when you run hardhat node)
    • ChainID: 31337
    • Name your network currency
    • Save network

    image

  7. To Deploy on sepolia

    npx hardhat ignition deploy ./ignition/modules/cc.js --network sepolia
    

    remeber to enable sepolia on metamask to access it

Back-end:

Go to backend folder

  1. Create virtual env (not needed in windows):
    pip install virtualenv
    python<version> -m venv <virtual-environment-name>
    
  2. Activate the virtual env:
    source env/bin/activate
    
  3. Install requirements:
    pip install requirements.txt
    
  4. Run Backend:
    python run.py
    

Front-end:

Go to client folder

  1. run:
    npm install
    
  2. Start client:
    npm start
    

References: