<figure><img src="image_1.png" /></figure>

HAL
open science

# Blockchain Hate Logger: Immutable Logging of Detected Hate Speech Using DeHateBERT

Muhammad Osama Nusrat, Saad Ahmed Jamal

<figure><img src="image_2.png" /></figure>

## To cite this version:

Muhammad Osama Nusrat, Saad Ahmed Jamal. Blockchain Hate Logger: Immutable Logging of Detected Hate Speech Using DeHateBERT. 2025. hal-05050174

HAL Id: hal-05050174

https://hal.science/hal-05050174v1

Preprint submitted on 28 Apr 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_3.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Blockchain Hate Logger: Immutable Logging of Detected Hate Speech Using DeHateBERT

1st Muhammad Osama Nusrat

Dept of Computing

National University of Computer and Emerging Sciences

Islamabad, Pakistan

i212169@nu.edu.pk

2nd Saad Ahmed Jamal

MED-IIFA

University of Evora

Évora, Portugal

saad.jamal@uevora.pt

**Abstract**—The rise of hate speech on social media platforms presents significant challenges for content moderation, transparency, and user trust. Although hate speech classification has been widely explored using models such as DeHateBERT, existing moderation systems often lack accountability, and flagged content can be altered or removed without trace. In this paper, we present Blockchain Hate Logger a system that detects and immutably logs hate speech using a transformer-based text classifier (DeHateBERT) and Ethereum smart contracts. We use the HateXplain dataset to classify 25,000 tweets into normal, offensive, or hate categories. For each flagged tweet, we compute a SHA-256 hash and store it along with the predicted label, model confidence, and timestamp on a smart contract deployed via Ganache, a local Ethereum blockchain. This ensures tamper-proof, verifiable moderation logs. We analyze over 1,000 transactions, estimate gas costs, and present trends in label distribution, confidence scores, and time-based logging. Our work builds on prior efforts in hate speech detection, fairness, and explainability, and demonstrates the feasibility of integrating NLP and blockchain for auditable AI content moderation. The full implementation is available at: https://github.com/mnusrat786/realtime-hate-logger.

## I. INTRODUCTION

Hate speech on social media poses a growing threat to online safety, especially as platforms struggle to moderate content at scale. Automated hate speech detection using machine learning has made significant progress, yet real-world deployment remains limited by issues of transparency, verifiability, and trust. Even when harmful content is detected, the moderation process is often opaque and prone to deletion, raising concerns around accountability and bias.

Recent work has focused on improving classification accuracy using models such as DeHateBERT [1] and multilingual deep learning techniques [2]. However, these systems typically operate within centralized platforms, offering no guarantee that moderation decisions or detected content remain traceable after being flagged. Moreover, explanations for why content was labeled as hate or offensive are often missing or inaccessible to the public, leading to further criticism of AI-based moderation [3, 4].

To address these gaps, we introduce **Blockchain Hate Logger**, a system that performs hate speech detection and logs detected content to a tamper-proof, verifiable public ledger. Our method combines the DeHateBERT classifier with SHA-256 hashing and Ethereum smart contracts, deployed locally

via Ganache. Instead of storing full content, we hash each flagged tweet and log its hash along with the prediction label, model confidence, and timestamp. This ensures immutability while preserving privacy.

We evaluate our system on a subset of 25,000 tweets from the HateXplain dataset. The DeHateBERT classifier identified 1,534 tweets as hate or offensive. From these, the top 1,000 high-confidence samples were hashed and immutably logged to the blockchain. We further analyze model confidence distribution, temporal logging behavior, and gas consumption, and verify hash uniqueness to demonstrate content integrity and tamper-resistance.

**Our contributions are as follows:**

* We propose a novel integration of hate speech detection and blockchain-based logging to create tamper-proof moderation records.

* We demonstrate the use of DeHateBERT and SHA-256 hashing in logging model outputs to an Ethereum smart contract.

* We analyze the cost, scalability, and behavior of this system using 1,025 blockchain transactions and confidence-based evaluation.

## II. RELATED WORK

### A. Hate Speech Detection

Hate speech detection has been extensively studied using machine learning and deep learning approaches. Early efforts focused on keyword-based filtering and logistic classifiers, which were limited in nuance. The release of the HateXplain dataset introduced explainable hate speech labels and ratios, advancing research toward interpretability [1]. More recent transformer-based models such as DeHateBERT have been fine-tuned on such datasets to improve detection of hate, offensive, and normal speech. Aluru et al. [2] explored multilingual detection across diverse languages and cultures, highlighting generalization challenges.

### B. Explainability and Fairness

Model explainability is crucial for transparency in moderation systems. Ribeiro et al. [3] introduced LIME, a technique to explain the predictions of any classifier locally. Fairness and algorithmic justice in automated decision-making have also
drawn attention, particularly regarding perceived fairness and
the role of political philosophy in ML [4, 5]. Barocas et al.
[6] further discuss limitations and tradeoffs in fairness-aware
machine learning.

### C. Blockchain and Content Moderation

Blockchain has been explored for transparency in social
media moderation. Hisseine et al. [7] provide a systematic
review of blockchain applications in social media, emphasizing
trust, immutability, and decentralized governance. InterPlane-
tary File System (IPFS) has been used for content-addressable
storage [8]. However, few systems combine hate detection,
hashing, and smart contract logging. Our work fills this gap
by demonstrating how NLP models and blockchain can be
integrated for verifiable, tamper-resistant moderation records.

## III. METHODOLOGY

Our system, **Blockchain Hate Logger**, integrates
transformer-based hate speech detection with blockchain
logging to provide verifiable, privacy-preserving moderation
records. Different deep learning models were studied to work
with tweets data to come with the latest advancement [9, 10].
A number of techniques have been tested in previous research
to incorporate modalities with neural networks for multi task
learning [11]. The architecture consists of four core modules:
data ingestion, classification, hash generation, and smart
contract logging.

### A. Model and Segments

1) **DeHateBERT Classifier:** We utilize DeHateBERT, a BERT variant fine-tuned on the HateXplain dataset [1], to classify tweets into three categories: normal (0), offensive (1), or hate (2). For each input, the model outputs a class label and a softmax confidence score, which we scale to a 0-100 range prior to logging.

2) **Hashing Module:** To maintain user privacy and reduce blockchain storage costs, raw tweet content is not logged. Instead, each offensive or hateful tweet is hashed using SHA-256. The resulting digest acts as a tamper-proof fingerprint, enabling later verification without content exposure.

3) **Smart Contract Deployment:** A custom Solidity smart contract is deployed on a local Ethereum blockchain (Ganache). Each log entry consists of the tweet hash, label, scaled confidence score, and timestamp. Web3.py is used to sign and submit transactions. We track gas consumption based on actual transaction receipts to assess scalability.

4) **Workflow Summary:** The complete pipeline operates as follows:

1) Tweets are processed in batch using DeHateBERT.

2) Tweets labeled as offensive or hate are selected.

3) SHA-256 hashes are computed for the flagged texts.

4) Each hash, along with the label, confidence, and timestamp, is recorded on-chain via the smart contract.

This architecture ensures high-integrity logging of AI mod-
eration decisions while preserving privacy and auditability.

### B. System Architecture

The overall architecture of the Blockchain Hate Logger is shown in Figure 1. The system processes incoming tweets using DeHateBERT to classify them. Tweets labeled as offensive or hate are filtered, hashed using SHA-256, and sent to a smart contract deployed on Ethereum. The contract logs the hash, label, confidence score, and timestamp immutably to the blockchain.

<figure><img src="image_4.png" /><figcaption>Fig. 1. System architecture of Blockchain Hate Logger</figcaption></figure>

### C. Experiment Setup

1) **Dataset:** We used the HateXplain dataset [1], which contains approximately 40,000 labeled tweets annotated into three categories: normal (0), offensive (1), and hate (2). For our experiment, we selected a random subset of 25,000 tweets for evaluation. Each tweet is passed through the DeHateBERT classifier to obtain a label and model confidence.

2) **Model and Confidence Threshold:** DeHateBERT is used as a black-box model for prediction. Tweets labeled as either *offensive* or *hate* are logged to the blockchain. We did not apply any minimum confidence threshold in order to observe the full model behavior in real-world conditions.

3) **Blockchain Environment:** We used the Ganache local Ethereum blockchain for smart contract deployment and transaction testing. Each transaction logs the following fields:

* SHA-256 hash of the tweet

* Predicted label (0, 1, or 2)

* Confidence score (0-100)

* Timestamp of detection

A Solidity smart contract was deployed to Ganache and interacted with via Web3.py. The average gas cost per transaction was computed using actual on-chain logs.

4) **Implementation Tools:**

* **Language:** Python 3.10

* **Libraries:** Transformers (for DeHateBERT), Web3.py, Pandas, Matplotlib

* **Blockchain:** Ganache CLI, Solidity, MetaMask (for testing)

* **Hardware:** Intel i7 CPU, 16GB RAM, no GPU acceleration
5) *Data Logged*: Out of the 25,000 tweets processed, the model identified 1,534 as offensive or hate. The top 1,000 most confident samples were logged to the blockchain to maintain performance and manage transaction costs.

## IV. RESULTS AND DISCUSSION

### A. *Experimental Summary*

We processed 25,000 tweets using the DeHateBERT model. The system flagged a total of 1,534 tweets as either offensive or hate. To manage performance and cost, the top 1,000 high-confidence entries were hashed and logged to the blockchain using a custom smart contract.

1) *Label Distribution:* Figure 2 shows the number of logged tweets per predicted label, where **0 = hate**, **1 = offensive**, and **2 = normal**. Most entries were labeled as *normal*, followed by *hate* and *offensive*.

<figure><img src="image_5.png" /><figcaption>Fig. 2. Label Distribution in Blockchain Logs</figcaption></figure>

2) *Model Confidence Statistics:* We computed confidence statistics for each label (Table I). The model was most confident in predicting *normal* tweets and least confident in detecting *hate*.

Figure 3 visualizes the overall distribution of model confidence scores across the logged entries. The histogram is right-skewed, indicating that the model often assigned high confidence scores when flagging tweets. This aligns with the summary statistics in Table I, where *normal* tweets had the highest mean confidence, followed by *offensive* and *hate*. The sharp peak near the upper confidence range supports our decision to select high-confidence samples for blockchain logging.

<table><caption>TABLE I
CONFIDENCE STATISTICS BY LABEL</caption><thead><tr><td>Label</td><td>Mean</td><td>Std Dev</td><td>Min</td><td>Max</td></tr></thead><tbody><tr><td>Normal (0)</td><td>84.34</td><td>8.54</td><td>50</td><td>91</td></tr><tr><td>Offensive (1)</td><td>80.74</td><td>8.94</td><td>50</td><td>90</td></tr><tr><td>Hate (2)</td><td>76.67</td><td>9.45</td><td>50</td><td>91</td></tr></tbody></table>

<figure><img src="image_6.png" /><figcaption>Fig. 3. Model Confidence Histogram</figcaption></figure>

3) *Temporal Logging Behavior:* We plotted the number of entries logged over time (Figure 4), aggregated per minute. The graph shows a surge in activity during a short window, reflecting the batch-based offline processing of tweets. This highlights the system's ability to efficiently handle large-scale hate speech detection and immutable logging within seconds.

<figure><img src="image_7.png" /><figcaption>Fig. 4. Logged Entries Over Time (Per Minute)</figcaption></figure>

4) *Blockchain Gas Cost:* Each transaction used approximately 148,457 gas units. The total gas cost for 1,025 entries was:

* **Total Gas Used:** 152,670,425

* **Gas Price:** 10 Gwei

* **Total ETH:** ~1.52 ETH

* **Average per Entry:** 0.00148 ETH

5) *Hash Verification:* To verify immutability, we rehashed three sample tweets with different content. None of the recalculated hashes matched the originals, confirming the sensitivity of hash-based integrity tracking. The results are shown in Table II, which demonstrates that even slight content changes produce completely different hashes, ensuring tamper-evident logging on the blockchain.

<table><caption>TABLE II
HASH VERIFICATION OF BLOCKCHAIN LOGS</caption><thead><tr><td>Original Hash (Truncated)</td><td>Recalculated Hash</td><td>Match</td></tr></thead><tbody><tr><td>a2bcb467...f0b9a8e</td><td>a112f95c...f36fd38</td><td>No</td></tr><tr><td>2e603d4b...4e6e2a7</td><td>a112f95c...f36fd38</td><td>No</td></tr><tr><td>aeaa499e...fbd4993</td><td>a112f95c...f36fd38</td><td>No</td></tr></tbody></table>
## B. Discussion and Interpretations

Our results demonstrate that blockchain technology can be effectively combined with modern hate speech detection models to produce tamper-proof, verifiable moderation logs. By logging only the SHA-256 hashes of flagged tweets, we ensured that user privacy is preserved while still enabling traceability and proof of detection.

The model's confidence scores varied across classes, with lower average confidence for hate speech than for normal content. This suggests that hate content remains more ambiguous and harder to classify, aligning with prior research on the limitations of automated moderation [12, 13].

From a system performance standpoint, logging 1,025 entries to the blockchain incurred an estimated total cost of 1.52 ETH. While this is feasible in controlled environments such as local blockchains (Ganache), real-world deployment on public blockchains would require cost optimization strategies, such as batch logging, roll-ups, or layer-2 solutions.

The hash verification test confirmed the immutability of the logs. Even slight changes in tweet content result in entirely different hash values, preventing tampering or replay attacks. This demonstrates the potential of blockchain as an audit trail for automated moderation.

Finally, our temporal logging data shows the system is capable of near-real-time performance under batch processing conditions. This makes it suitable not only for forensic archiving but also for integration into live moderation dashboards.

## C. Limitations and Future Work

Although our system demonstrates the feasibility of using blockchain to log hate speech detection results, there are several limitations.

1) *Gas Costs on Public Blockchains:* Our experiments were conducted on a local blockchain using Ganache, where gas costs are not a constraint. Deploying this system on public blockchains like Ethereum Mainnet would incur significant financial costs per transaction. Future work could explore the use of Layer-2 solutions, such as Optimism or Arbitrum, or alternative platforms like Polygon for lower transaction fees.

2) *Content Retrieval:* Since only SHA-256 hashes are stored on-chain, content retrieval requires access to the original tweet dataset. In real-world deployments, linking hashes to off-chain IPFS storage could preserve privacy while allowing content verification.

3) *Model Limitations:* The DeHateBERT classifier, while accurate, is limited by dataset biases and can misclassify nuanced or context-dependent speech. Incorporating ensemble models or model explanations (e.g., LIME [3]) could enhance reliability and fairness.

4) *Real-time Deployment:* Our current implementation works in batch mode. To deploy in real time, the system would require asynchronous processing, scalability testing, and potentially a message queue or event-driven architecture.

5) *User Transparency:* While the system logs detections immutably, it does not currently provide any user-facing transparency interface. Future versions could include a dashboard for moderators or public transparency portals to view hashed moderation logs.

## V. CONCLUSION

In this paper, we presented **Blockchain Hate Logger**, a modular system that combines state-of-the-art hate speech detection with blockchain-based logging to ensure verifiability, traceability, and integrity of moderation records. By integrating the DeHateBERT classifier with a SHA-256 hashing mechanism and a smart contract deployed on an Ethereum-compatible blockchain, we demonstrated how flagged content can be recorded immutably without compromising user privacy.

Our evaluation on 25,000 tweets from the HateXplain dataset showed that 1,025 offensive or hate-labeled samples were successfully hashed and logged. We analyzed label distributions, confidence scores, and gas costs associated with the logging process. We also verified the tamper-resistance of the system through hash mismatch testing.

This work highlights a viable path toward transparent and auditable AI content moderation. Future extensions of this system could incorporate lower-cost blockchain solutions, multilingual classification, real-time deployment, and user-facing transparency dashboards as well as spatial analysis by incorporating location of tweets.

## ETHICAL CONSIDERATIONS

This system is designed to promote transparency and accountability in AI-driven content moderation. No user data is stored on-chain, and all tweet content is hashed to protect privacy. We acknowledge that automated moderation systems can reflect biases in training data and encourage caution in their deployment.

## ACKNOWLEDGEMENTS

We thank the maintainers of the HateXplain dataset and the open-source communities behind DeHateBERT, Web3.py, and Ganache. Their contributions enabled the successful development of this system. The second author was supported by research fund EURAXESS Grant ID:186817, Mobilizing Agenda: Sines Nexus, with reference "C645112083-00000059" co-financed by the PRR - Recovery and Resilience Plan.

## REFERENCES

[1] B. Mathew, P. Saha, S. M. Yimam, C. Biemann, P. Goyal, and A. Mukherjee, "Hatexplain: A benchmark dataset for explainable hate speech detection," in *Proceedings of the AAAI conference on artificial intelligence*, vol. 35, no. 17, 2021, pp. 14867–14875.

[2] S. S. Aluru, B. Mathew, P. Saha, and A. Mukherjee, "Deep learning models for multilingual hate speech detection," *arXiv preprint arXiv:2004.06465*, 2020.

[3] M. T. Ribeiro, S. Singh, and C. Guestrin, "" why should i trust you?" explaining the predictions of any classifier," in *Proceedings of the 22nd ACM SIGKDD international*
*conference on knowledge discovery and data mining*, 2016, pp. 1135–1144.

[4] R. Binns, M. Van Kleek, M. Veale, U. Lyngs, J. Zhao, and N. Shadbolt, "'it's reducing a human being to a percentage' perceptions of justice in algorithmic decisions," in *Proceedings of the 2018 Chi conference on human factors in computing systems*, 2018, pp. 1–14.

[5] R. Binns, "Fairness in machine learning: Lessons from political philosophy," in *Conference on fairness, accountability and transparency*. PMLR, 2018, pp. 149–159.

[6] S. Barocas, M. Hardt, and A. Narayanan, *Fairness and machine learning: Limitations and opportunities*. MIT press, 2023.

[7] M. A. Hisseine, D. Chen, and X. Yang, "The application of blockchain in social media: a systematic literature review," *Applied Sciences*, vol. 12, no. 13, p. 6567, 2022.

[8] J. Benet, "Ipfs-content addressed, versioned, p2p file system," *arXiv preprint arXiv:1407.3561*, 2014.

[9] M. O. Nusrat, W. Shahzad, and S. A. Jamal, "Multi-class depression detection through tweets using artificial intelligence," 2024, https://doi.org/10.48550/arXiv.2404.13104. [Online]. Available: https://arxiv.org/abs/2404.13104

[10] M. O. Nusrat, Z. Habib, M. Alam, and S. A. Jamal, "Emoji prediction in tweets using bert," 2023, https://doi.org/10.48550/arXiv.2307.02054. [Online]. Available: https://arxiv.org/abs/2307.02054

[11] S. A. Jamal and A. Aribisala, "Data fusion for multi-task learning of building extraction and height estimation," 2023, https://doi.org/10.48550/arXiv.2308.02960. [Online]. Available: https://arxiv.org/abs/2308.02960

[12] B. Vidgen, A. Harris, D. Nguyen, R. Tromble, S. Hale, and H. Margetts, "Challenges and frontiers in abusive content detection," in *Proceedings of the third workshop on abusive language online*. Association for Computational Linguistics, 2019.

[13] M. S. Jahan and M. Oussalah, "A systematic review of hate speech automatic detection using natural language processing," *Neurocomputing*, vol. 546, p. 126232, 2023.