You can use Silence Unknown Callers to block spam calls on your iPhone.
Turn on Silence Unknown Callers
With iOS 13 and later, you can turn on Silence Unknown Callers to avoid getting calls from people you don’t know. This blocks phone numbers that you’ve never been in contact with and don’t have saved in your contacts list. If you’ve previously texted with someone using their phone number or if a person has shared their phone number with you in an email, a phone call from that number will go through.
To turn on Silence Unknown Callers, go to Settings > Phone, then scroll down, tap Silence Unknown Callers, and turn on the feature. Calls from unknown numbers are silenced and sent to your voicemail, and appear in your recent calls list.
Incoming calls will come through from people that are saved in your contacts list, recent calls list, and from Siri Suggestions to let you know who’s calling based on phone numbers included in your emails or text messages.
If an emergency call is placed, Silence Unknown Callers will be temporarily disabled for the next 24 hours to allow for your iPhone to be reached.
Before you turn on Silence Unknown Callers, make sure you have important contacts saved or you could miss a phone call that you don’t want to miss. The call will still go to voicemail and appear in your recent calls list, but you won’t get a notification while the call is ringing.
(This how-to is based on my experiences and info on Apple’s support pages.)