To provide partners with a transparent view of their retired carbon credits, we utilize a Streamlit dashboard. This Python-based web application interfaces with the Global Hemp Ledger via Web3.py to fetch “Retirement Events” and retrieves the associated environmental proof from IPFS.
The “Retirement Dashboard” Architecture
Python Script: ghl_dashboard.py
import streamlit as st
import pandas as pd
from web3 import Web3
import requests
import json
# --- CONFIGURATION ---
RPC_URL = "https://rpc.planethemp.one"
CONTRACT_ADDRESS = "0xYourContractAddressHere"
IPFS_GATEWAY = "https://ipfs.io/ipfs/" # Or your local Nexus gateway
ABI = json.loads('[...your_contract_abi...]')
# Initialize Web3
w3 = Web3(Web3.HTTPProvider(RPC_URL))
contract = w3.eth.contract(address=CONTRACT_ADDRESS, abi=ABI)
st.set_page_config(page_title="Planet Hemp | Retirement Dashboard", layout="wide")
def fetch_ipfs_metadata(cid):
"""Retrieves environmental proof from the Data Commons."""
try:
response = requests.get(f"{IPFS_GATEWAY}{cid}", timeout=5)
return response.json()
except:
return None
def get_retirement_events():
"""Queries the Ledger for all CarbonRetired events."""
events = contract.events.CarbonRetired().get_logs(from_block=0)
data = []
for event in events:
args = event['args']
data.append({
"Beneficiary": args['beneficiary'],
"Amount (Tons)": args['amount'],
"Reason": args['reason'],
"Timestamp": pd.to_datetime(args['timestamp'], unit='s'),
"CID": args['evidenceCID'],
"TxHash": event['transactionHash'].hex()
})
return pd.DataFrame(data)
# --- DASHBOARD UI ---
st.title("🌿 Global Hemp Ledger: Retirement Explorer")
st.markdown("Verify the permanent sequestration of atmospheric carbon through our decentralized audit trail.")
# Summary Metrics
df = get_retirement_events()
col1, col2, col3 = st.columns(3)
col1.metric("Total CO2 Retired", f"{df['Amount (Tons)'].sum()} Tons")
col2.metric("Active Partners", df['Beneficiary'].nunique())
col3.metric("Ledger Integrity", "100% Verified")
st.divider()
# Certificate View
st.subheader("📜 Issued Certificates of Sequestration")
for index, row in df.iterrows():
with st.expander(f"Certificate: {row['Beneficiary']} - {row['Amount (Tons)']} Tons"):
c1, c2 = st.columns([2, 1])
with c1:
st.write(f"**Reason:** {row['Reason']}")
st.write(f"**Retired On:** {row['Timestamp']}")
st.code(f"Tx Hash: {row['TxHash']}")
st.link_button("View on Ledger Explorer", f"https://explorer.planethemp.one/tx/{row['TxHash']}")
with c2:
# Fetch real-time data from IPFS for this specific harvest
metadata = fetch_ipfs_metadata(row['CID'])
if metadata:
st.info("📊 Environmental Proof")
st.json(metadata['telemetry']) # Displays soil moisture, NPK, etc.
else:
st.warning("Metadata fetching from IPFS...")
st.sidebar.image("https://planethemp.one/logo.png", width=200)
st.sidebar.title("Partner Portal")
selected_partner = st.sidebar.selectbox("Filter by Beneficiary", ["All"] + list(df['Beneficiary'].unique()))
if selected_partner != "All":
st.write(f"Showing results for: **{selected_partner}**")
Key Features for Partners
-
Immutable Proof: Partners can see the exact transaction hash on the GHL, making it impossible to “double-spend” carbon offsets.
-
Telemetry Transparency: By pulling from IPFS, the dashboard shows the actual soil and air metrics collected by Eco-Guardian sensors during the growth of that hemp.
-
Real-Time Analytics: The summary metrics at the top update instantly as more carbon is retired across the network.
Running the Dashboard
Developers can launch this locally or on a server within the TDCC by running:
pip install streamlit web3 pandas requests
streamlit run ghl_dashboard.py










Discussion (0)
There are no comments for this doc yet.