Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

How to Architect a System for Handling Right to Erasure Requests

A technical guide for developers on designing systems to partially fulfill data erasure ('right to be forgotten') requests in the context of immutable blockchains.
Chainscore © 2026
introduction
ARCHITECTURE GUIDE

Introduction to Data Erasure on Immutable Ledgers

A technical guide for designing systems that comply with data privacy regulations like GDPR's Right to Erasure within the constraints of immutable blockchain infrastructure.

The Right to Erasure (Right to be Forgotten), a cornerstone of regulations like the GDPR, presents a fundamental conflict with blockchain's core property of immutability. Architecting a compliant system requires a nuanced approach that separates mutable application state from the immutable ledger. This guide outlines architectural patterns for handling erasure requests without compromising the integrity of the underlying chain. The goal is to move from storing personal data on-chain to storing references to data that can be managed off-chain.

The primary architectural pattern is the Separation of Data and Consensus. Instead of storing raw personal data in a smart contract's state or transaction calldata, store only a cryptographic commitment—typically a hash—on-chain. The corresponding plaintext data is stored in a mutable, permissioned off-chain database or a content-addressable storage system like IPFS or Arweave. The on-chain hash acts as a tamper-proof proof of the data's existence and state at a specific point in time, while the off-chain component allows for deletion.

For the off-chain component, implement a Custodial Data Service with strict access controls. This service manages the lifecycle of the plaintext data. When a valid erasure request is authenticated, the service permanently deletes the plaintext data from its database and revokes access permissions. The on-chain hash remains, but it now points to data that is no longer retrievable, effectively fulfilling the erasure requirement. This model is used by systems handling verifiable credentials or selective disclosure of identity attributes.

A more advanced pattern involves state channels or layer-2 solutions. Here, personal data interactions occur off-chain, with only the final state commitments or dispute proofs settled on the base layer (L1). Erasure can be handled entirely within the off-chain protocol rules before finalization. For existing, problematic on-chain data, consider a redaction-with-proof model. This involves publishing a new transaction that nullifies the old data's utility (e.g., burning a token that references it) and optionally storing a zero-knowledge proof that the redaction was performed correctly, without revealing the original data.

Smart contract design is critical. Contracts should not use msg.sender or wallet addresses as direct primary keys for personal data, as these are immutable identifiers. Instead, use pseudonymous identifiers like incremental IDs or randomly generated UUIDs that can be dissociated from a user. Implement an access control registry that maps these identifiers to updatable encryption keys. To erase, the contract can delete the key mapping, rendering the on-chain ciphertext permanently inaccessible. Always include a clear data policy and audit trail of erasure actions on-chain for regulatory compliance.

In practice, evaluate the trade-offs. Zero-knowledge proofs (ZKPs) offer a powerful tool for proving compliance (e.g., proving a user is over 18 without storing their birthdate) but add complexity. For many applications, a hybrid architecture using decentralized storage with mutable pointers (like Ceramic Network streams) provides a pragmatic solution. The key is to document the data flows, ensure secure deletion processes, and verify that your architectural choice meets the specific legal interpretation of 'erasure' applicable to your users.

prerequisites
ARCHITECTURE FOUNDATIONS

Prerequisites and System Assumptions

Before implementing a system for handling Right to Erasure (RTE) requests, you must establish a clear architectural foundation. This section outlines the core technical and organizational prerequisites your system must satisfy to be compliant, secure, and scalable.

Your system must have a complete data inventory. This is a non-negotiable prerequisite. You need a machine-readable map of all personal data stores, including on-chain data (e.g., wallet addresses, transaction hashes in smart contract state), off-chain databases (user profiles, KYC records), and external vendor systems. For each data point, document its purpose of processing, legal basis (e.g., consent, contract), and retention period. Tools like data discovery scanners or manually maintained registries are essential. Without this map, you cannot reliably locate data for erasure.

A robust identity verification and request intake layer is critical. You must be able to cryptographically verify that the requester owns the data in question. For blockchain systems, this typically involves requesting a signature from the associated wallet address. For off-chain data linked to an email or username, standard authentication flows apply. This layer should log all incoming requests with a unique ticket ID, the verified identifier (e.g., 0x742d...), the request scope, and its timestamp to create an audit trail, as mandated by regulations like GDPR.

Your architecture must enforce data isolation by legal basis. Personal data processed under consent must be stored separately from data processed under contractual necessity or legitimate interest. This isolation allows you to erase data where consent is withdrawn while preserving data you are legally obligated to keep. In a database schema, this means using different tables or schemas with clear foreign key relationships. In smart contracts, consider separate mappings or contracts for consent-based data versus operational data.

You need a unified erasure orchestration engine. This component consumes verified requests from the intake layer, queries the data inventory to identify all storage locations, and executes deletion commands. It must handle both soft delete (flagging records as inactive) and hard delete (permanent removal), based on your retention policy and the need for non-repudiation in audit logs. The engine should have idempotent operations to safely retry failed deletions and must propagate deletions to all downstream processors and third-party vendors via API calls.

Finally, assume the need for cryptographic proof and immutable logging. For blockchain applications, you cannot delete on-chain data. Your architecture must instead implement a deletion certificate system. When an RTE request is processed, your orchestration engine should write a transaction to a public ledger (or a dedicated sidechain) that attests to the off-chain deletion and the invalidation of the on-chain identifier. This creates a permanent, verifiable record of compliance. Use a standard like W3C Verifiable Credentials for these attestations.

key-concepts-text
GDPR ARTICLE 17 IMPLEMENTATION

Architecting Systems for Partial Data Erasure

A technical guide for engineers on designing blockchain and database systems that can selectively delete personal data to comply with the 'right to erasure'.

The right to erasure (or 'right to be forgotten'), mandated by regulations like the GDPR, presents a unique challenge for immutable systems like blockchains. Unlike traditional databases where a DELETE command is straightforward, distributed ledgers are designed for permanence. Partial erasure is the architectural pattern of logically or cryptographically obscuring specific data points while preserving the system's overall integrity and audit trail. This requires moving beyond simple CRUD operations to a design that separates data storage from data accessibility.

A foundational concept is the separation of on-chain references from off-chain data. Sensitive personal information (e.g., a user's name or email) should not be stored directly in a smart contract's state or a transaction's calldata. Instead, store only a cryptographic commitment—like a hash—on-chain. The actual data is kept in a mutable, permissioned off-chain database (IPFS with mutable pointers, a centralized API, or a decentralized storage network with deletion capabilities). The on-chain hash acts as an immutable proof of the data's state at a point in time, while the off-chain storage layer handles erasure requests.

For data that must reside on-chain, cryptographic erasure techniques like shamir's secret sharing or proxy re-encryption can be employed. Instead of storing plaintext, data is encrypted with a user-specific key. The system can then 'erase' the data by discarding or cryptographically nullifying the decryption key, rendering the on-chain ciphertext permanently inaccessible. Zero-knowledge proofs can further enhance this by allowing the system to prove a property about the data (e.g., 'this user is over 18') without revealing the underlying data itself, minimizing what needs to be stored and later erased.

Implementing erasure logic requires careful smart contract design. A common pattern is an access control registry that maps user identifiers to a revocation status. Your core contract logic must check this registry before returning any user data. For example:

solidity
function getUserData(address user) public view returns (string memory) {
    require(!erasureRegistry.isErased(user), "Data erased");
    return userData[user];
}

When an erasure request is verified, an authorized admin or a decentralized oracle updates the registry, effectively hiding the data from all future contract interactions, while the historical state remains in the blockchain's past blocks.

Architecting for erasure also impacts data indexing and event logging. Off-chain indexers (like The Graph) must respect erasure flags and filter out deleted data from their APIs. Similarly, applications should avoid emitting full personal data in unencrypted event logs, as these are permanently readable. Emit only pseudonymous identifiers or hashes, and maintain a queryable service for the plaintext data that respects erasure controls. This layered approach—immutable core, mutable access layer—balances regulatory compliance with blockchain's core value proposition of verifiable history.

architectural-patterns
GDPR & DATA COMPLIANCE

Architectural Patterns for Erasure

Technical approaches for building systems that can efficiently and verifiably handle user data deletion requests, a core requirement of regulations like GDPR and CCPA.

01

Pseudonymization & Data Minimization

Design systems that store the minimum data necessary and use pseudonymous identifiers (hashes, UUIDs) instead of direct PII. This limits the blast radius of an erasure request.

  • Example: Store a hash of a user's email as their primary key, with the plaintext email in a separate, encrypted table.
  • Benefit: Deleting the mapping record effectively severs the link between the identifier and the user's identity across all related data tables.
02

Soft Deletion with Cryptographic Proof

Implement a soft delete pattern where records are marked as deleted but retained for audit trails. Use a cryptographic proof, like a Merkle proof, to allow users to verify their data was flagged for deletion without exposing other users' data.

  • How it works: Maintain a registry of deletion requests on-chain or in an immutable log. Users can query their specific proof of inclusion.
  • Tools: This pattern is used by projects like Bloom for consent revocation and can be implemented with libraries like MerkleTreeJS.
03

Event Sourcing & CQRS

Adopt an Event Sourcing architecture where state changes are stored as an immutable sequence of events. To erase a user, you append a "UserDataErasureRequested" event. The CQRS (Command Query Responsibility Segregation) read model is then rebuilt, excluding data from erased users.

  • Advantage: Provides a complete, verifiable audit log of all data-related actions, including deletions.
  • Challenge: Requires careful design of event schemas to ensure PII is not permanently embedded in immutable events.
04

Zero-Knowledge Proofs for Compliance

Use Zero-Knowledge Proofs (ZKPs) to prove compliance with erasure requests without revealing underlying data. A system can generate a ZK proof that a user's data has been removed from a dataset or that an aggregate calculation (e.g., total revenue) is correct post-erasure.

  • Use Case: A DeFi protocol can prove its total value locked is accurate even after removing a user's contribution, preserving privacy.
  • Frameworks: Circom and SnarkJS are used to create such circuits for on-chain verification.
05

On-Chain Deletion Registries

Leverage public blockchains as a neutral, tamper-proof ledger for recording erasure requests. Smart contracts can manage a permissioned list of pseudonymous user IDs marked for deletion. Downstream services (indexers, APIs) must query this registry and filter their responses.

  • Implementation: An Ethereum or Polygon smart contract with a mapping like address => deletionTimestamp.
  • Verifiability: Anyone can audit the contract to see which identifiers have requested erasure and when.
06

Automated Data Discovery & Mapping

Implement automated tools to discover all data stores containing a user's PII. This is critical for microservices architectures. Use data lineage tools and tagging at the point of data creation.

  • Process: Tag all user data entries with a consistent, pseudonymous user ID. Use graph databases to map data flows.
  • Tools: Open-source solutions like OpenMetadata or Amundsen can help track data provenance, though they may require customization for erasure workflows.
ARCHITECTURAL APPROACHES

Erasure Pattern Comparison

Comparison of common technical patterns for implementing data erasure in blockchain-based systems, evaluating trade-offs in compliance, data integrity, and operational complexity.

Feature / MetricCryptographic DeletionState NullificationOff-Chain Deletion

GDPR Article 17 Compliance

On-Chain Data Permanence

Gas Cost per Request

$50-150

$5-20

$1-5

Audit Trail Integrity

Implementation Complexity

High

Medium

Low

Time to Fulfill Request

< 1 block

< 1 block

1-5 min

Smart Contract Upgrade Required

Suitable for Public Data (NFTs, TXs)

implementation-offchain-deletion
ARCHITECTING FOR GDPR ARTICLE 17

Implementation: Secure Off-Chain Data Deletion

A technical guide for building systems that process and securely delete user data stored off-chain in response to Right to Erasure (Right to be Forgotten) requests.

The EU's General Data Protection Regulation (GDPR) Article 17 grants individuals the Right to Erasure, commonly known as the right to be forgotten. For Web3 applications, this presents a unique challenge: while on-chain data is immutable, most dApps rely heavily on off-chain data storage for scalability and cost efficiency. This data, which can include user profiles, transaction metadata, and application state, must be deletable upon request. Architecting for this right requires a clear separation between immutable ledger data and mutable application data, with robust processes to locate, verify, and permanently erase the latter.

A compliant architecture centers on a verifiable deletion workflow. The system must: 1) Authenticate the requester's identity and ownership of the data, 2) Locate all linked off-chain records (e.g., in centralized databases, IPFS, Arweave, or decentralized storage networks), 3) Execute secure deletion or cryptographic shredding, and 4) Provide cryptographic proof of deletion. This proof, often a verifiable credential or a signed transaction hash confirming the deletion operation, should be stored or provided to the user. Smart contracts can act as the orchestration and verification layer for this process, even if they don't store the data itself.

Implementing deletion for decentralized storage like IPFS requires specific strategies. Since content on IPFS is addressed by its CID (Content Identifier) and can be cached by nodes, true deletion is complex. A practical method involves encrypting user data before pinning it to IPFS via a service like Pinata or nft.storage, and storing the decryption key separately (e.g., in a secure, deletable database). Upon a deletion request, the application destroys the key, rendering the encrypted content on IPFS inaccessible garbage data. The proof of deletion is the transaction or log entry that records the key's destruction.

For structured databases, implement a tombstoning and purging pattern. Upon receiving a valid request, instead of an immediate hard delete, first mark the user record with a deletion_requested flag and a timestamp. This allows for a mandatory grace period (e.g., 30 days) for legal holds or request revocation. After the period elapses, a secure purge job permanently overwrites the data. All associated data—foreign keys in related tables, file paths in blob storage, logs—must be identified via a data lineage map and included in the purge. Audit logs of the request and deletion should be maintained separately for compliance.

Here is a simplified conceptual flow for a deletion API endpoint, using a smart contract as the request ledger:

solidity
// Pseudocode for a Deletion Request Smart Contract
function submitDeletionRequest(bytes32 userIdHash, bytes memory signature) public {
    require(verifySignature(userIdHash, signature, msg.sender), "Invalid signature");
    requests[userIdHash] = DeletionRequest(block.timestamp, msg.sender, RequestStatus.Pending);
    emit DeletionRequested(userIdHash, msg.sender);
}

An off-chain listener (oracle or backend service) watches for the DeletionRequested event, triggers the secure key deletion and data purging process, and finally calls a confirmDeletion function on the contract, storing the proof of completion on-chain.

Key technical considerations include data minimization at the design stage, maintaining an accurate data inventory, and implementing strict access controls for the deletion pipeline itself. Regular audits and testing of the deletion workflow are essential. By building these mechanisms, developers create accountable systems that respect user sovereignty over their data, bridging the gap between blockchain's permanence and regulatory requirements for data erasure.

implementation-cryptographic-rotation
DATA COMPLIANCE

Implementation: Cryptographic Key Rotation

A guide to architecting systems that can cryptographically enforce data erasure requests, such as GDPR's Right to be Forgotten, without compromising system integrity.

The Right to Erasure (or Right to be Forgotten) presents a unique challenge for decentralized and immutable systems. Traditional deletion is antithetical to blockchain's append-only nature. The solution is cryptographic key rotation: instead of deleting data, you render it permanently inaccessible by destroying the keys used to encrypt it. This approach transforms a data deletion request into a key management operation, allowing systems to comply with regulatory mandates while preserving the integrity of their underlying data structures and audit trails.

Architecting this system requires a clear separation between data at rest and the decryption keys. User data must be encrypted with a unique, symmetric data encryption key (DEK) before being written to persistent storage (e.g., a blockchain, database, or IPFS). This DEK is then itself encrypted with a master public key, creating a key encryption key (KEK). The ciphertext (encrypted data) and the KEK are stored, while the plaintext DEK is discarded. Access is only possible by decrypting the KEK with the corresponding master private key to recover the DEK, which then decrypts the data.

The core of the erasure mechanism is the key management service (KMS). This secure, highly available service holds the current master private key. When an erasure request is validated, the system triggers a key rotation event. The KMS generates a new master key pair, archives the old private key for a legally mandated period if required, and then securely destroys the old private key associated with the user's data. All data encrypted under the old key becomes cryptographically locked, as the sole means of decrypting its DEK has been eliminated. The public system continues to function with the new key for all other users.

Implementation requires careful design. Each data record must be tagged with a key version identifier linking it to a specific master key pair. The KMS must maintain a secure, versioned key registry. In practice, services like AWS KMS, Google Cloud KMS, or HashiCorp Vault can manage this lifecycle, providing APIs for key generation, rotation, and scheduled deletion. For blockchain applications, consider storing only content identifiers (like IPFS CIDs) on-chain, with the encrypted data and keys managed off-chain, executing the erasure logic via a verifiable oracle or trusted execution environment.

This architecture has critical implications. It introduces a centralized trust point in the KMS, which must be secured accordingly. Audit logs of all key rotation and destruction events are non-negotiable for compliance proofs. Furthermore, systems must handle data derived from the erased source (e.g., cached views, analytics aggregates), often requiring these to be flagged or regenerated. Properly implemented, cryptographic key rotation provides a robust, auditable method for honoring data sovereignty in systems where true deletion is not an option.

GDPR VS. CCPA VS. LGPD

Jurisdictional Requirements Overview

Key differences in Right to Erasure (Right to be Forgotten) requirements across major data protection regulations.

Requirement / ScopeGDPR (EU/UK)CCPA/CPRA (California)LGPD (Brazil)

Legal Basis for Erasure

Right to erasure (Art. 17). Multiple triggers including withdrawal of consent.

Right to deletion. Consumer must opt-out of sale/sharing for some triggers.

Right to deletion (Art. 18). Similar to GDPR, includes revoked consent.

Timeframe for Compliance

30 days (extendable to 60 with notice)

45 days (extendable to 90 with notice)

15 days (immediate blocking, deletion upon confirmation)

Architectural Burden (Data Discovery)

High. Must find all personal data across systems, including backups.

Medium-High. Must find personal data sold/shared for business purpose.

High. Must find all personal data in the processing cycle.

Third-Party Notification

Required. Must inform controllers processing the data.

Required. Must direct service providers to delete from their systems.

Required. Must communicate deletion to partners and third parties.

Exemptions for Blockchain

Limited. Immutability conflicts with erasure; may require technical measures like key deletion.

Limited. Similar conflict with immutable ledgers; anonymization may suffice.

Limited. Explicitly mentions difficulty with technologies that prevent deletion.

Penalty for Non-Compliance

Up to €20M or 4% global turnover

Up to $7,500 per intentional violation

Up to 2% revenue in Brazil, capped at 50M BRL

GDPR COMPLIANCE

Frequently Asked Questions

Common technical questions and solutions for developers implementing systems to handle Right to Erasure (Right to be Forgotten) requests under regulations like GDPR.

The primary challenge is designing a system that can irreversibly delete personal data while maintaining the integrity and consistency of the core application, especially in immutable or append-only systems like blockchains. Unlike a simple database DELETE operation, you must consider:

  • Data immutability: On-chain data cannot be altered, requiring alternative patterns like data encryption with key deletion.
  • Data propagation: Personal data often exists in backups, logs, search indices, and third-party services (e.g., The Graph for indexing).
  • Legitimate interests: Data may need to be retained for legal compliance (e.g., financial transaction records), requiring a pseudonymization strategy instead of deletion.
conclusion
IMPLEMENTATION SUMMARY

Conclusion and Best Practices

Successfully handling Right to Erasure (RTE) requests requires a robust, auditable, and privacy-by-design architecture. This guide concludes with key architectural principles and operational best practices.

A well-architected RTE system is built on immutable audit logs, cryptographic verification, and granular data mapping. The core components—the Request Manager, Data Discovery Engine, Deletion Executor, and Audit Logger—must operate asynchronously and idempotently. Use a persistent queue (like RabbitMQ or AWS SQS) to decouple request intake from processing, ensuring reliability under load. All actions, from request receipt to final verification, must be logged with a cryptographic hash (e.g., SHA-256) to create a non-repudiable chain of custody, which is critical for regulatory compliance audits.

For data discovery, maintain a centralized Data Lineage Registry that maps user identifiers (like user_id or wallet address) to all data stores: SQL tables, NoSQL collections, blob storage paths, and external vendor APIs. Implement this using a graph database (Neo4j) or a dedicated registry service. When processing deletion, prefer soft deletion (a deleted_at timestamp and data masking) over hard DELETE SQL commands. This allows for recovery from errors and supports legal hold requirements. For blockchain data, implement the tombstone pattern, storing deletion proofs on-chain while obfuscating off-chain indexed data.

Establish clear data retention policies to automatically purge soft-deleted records after a mandated period (e.g., 30 days). Your Deletion Verification Service should generate a proof artifact—a signed JSON document listing the hashes of deleted records and the audit trail hash—returned to the user. Regularly conduct dry-run audits by processing test requests against a staging environment to validate the discovery coverage and deletion logic. Monitor key metrics: request completion latency, discovery accuracy rate, and system error rates, alerting on any anomalies.

Finally, document the entire process for developers and compliance officers. Provide a clear API specification for submitting RTE requests and retrieving verification proofs. Educate engineering teams on privacy-by-design, ensuring new services automatically register their data schemas with the lineage registry. By treating data deletion as a first-class, automated workflow, you build user trust and create a defensible position against regulatory scrutiny. The code patterns and system design outlined here provide a foundation for a scalable and compliant RTE infrastructure.