Skip to content

Instantly share code, notes, and snippets.

@TonyGiorgio
Created June 10, 2024 15:19
Show Gist options
  • Save TonyGiorgio/72e6822fce3e0e9ee637aa116c4d2bf4 to your computer and use it in GitHub Desktop.
Save TonyGiorgio/72e6822fce3e0e9ee637aa116c4d2bf4 to your computer and use it in GitHub Desktop.

Delete All Nostr Notes

This sends a delete request to all relays that have your data. This is a best effort and will likely not work well enough to actually delete everything, or possibly anything. A lot of relays do not respect delete requests.

  1. First download a list of relays:
curl -o relays.json https://api.nostr.watch/v1/online
  1. Now compile nostr-tool (compiling is required because of recent changes I made that are not released yet).

  2. Run the script below, replacing {NSEC} with your nsec.

# Read the JSON file and extract URLs into an array
mapfile -t urls < <(jq -r '.[]' relays.json)

# Loop through each URL in the array and execute the command in the background
while true; do
  for url in "${urls[@]}"; do
    nostr-tool -r "$url" -p {NSEC} delete-profile --events-only --kinds 1 --kinds 4 --kinds 6 --kinds 7 --kinds 1984 --kinds 9734 --kinds 9735 --kinds 30311 --kinds 1311 --kinds 30023 --kinds 30078 --kinds 1063 --timeout 60 &
  done

  # Wait for all background processes to complete
  wait

  echo "Starting new loop iteration..."
  sleep 10

done
  1. Give permissions
chmod +x script.sh #or whatever you named it
  1. Run
./script.sh

Depending on how many notes you have, this may take awhile. It won't be perfect but its an attempt. Check your profile on a few nostr clients to see if it's done a good enough job (make sure to delete cached data otherwise events may still be there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment