Erasing everything on my current I phone besides contacts
Unless there’s a compelling reasons to not take the easy route:

ensure the iCloud backup is complete for all data
Restore the contacts after erasing all content and settings.

For 10,000 contacts, this takes about 10 minutes in my experience in the US. You might need more time to backup and restore the further away from Apple data centers you are, but contacts are very small amounts of data to back up and then restore.
When you sign in again after erasing the device, just don’t sign in to iCloud when asked. Skip it from the setup assistant screen.
Sign in later from the settings app so you can control and turn off all the items except contacts.