YOU NEED TO KNOW MORE FACTS
The age of consent to sex in the United States, in cases not involving child pornography (which is federally regulated as well as subject to state regulation) is a matter of state law, although federal law criminalizes crossing state lines for the purposes of sex with a minor in certain cases. There is moderate variation from state to state on this issue.
Many (probably most, but I haven't counted in a detailed survey) U.S. states have at least two separate components of a statutory rape law and a separate child prostitution law, to which different provisions regarding mistake of age apply.
One component of a typical state statutory rape law, which usually pertains to teenagers above a certain age, is a misdemeanor and includes a good faith mistake of age after reasonable investigation exception (at least if it does not involve commercial prostitution). This component also often has an "age gap" limitation for at least part of the age range that is sometimes a crime, to make sex not a crime if the couple are close in age (typically four years apart or ten years apart).
The other component of a typical state statutory rape law, which usually pertains to pre-pubescent minors, is usually a felony and does not have a mistake of age exception (this is sometimes called a strict liability statute even though you need to have an intent to do some things like an intent to voluntarily have sex). These laws have been upheld against constitutional due process challenges, at least as applied in particular cases. It is constitutional to have a statutory rape law with only a strict liability component. But it is relatively uncommon for a state to have such a law.
You need to know you are having sex with the person you think you are having sex with (if you were blindfolded and someone replaced your intended and believed partner with someone else without your knowledge, expectation, or consent, you would also be a rape victim, not a perpetrator and the child would be raped by the person arranging it even though you carried out the act unwittingly), but you don't constitutionally need to know that the person you are having sex with is under the statutory age and ignorance or mistake regarding the statutory age is no excuse.
In the U.S., state laws banning being a buyer of commercial prostitution by people under age eighteen, typically apply even if sex with that person would not be a crime if it was non-commercial, and typically do not have an exception for mistake of age, although statutes vary.
Also, many states, in addition to a statutory rape law also have a law prohibiting certain people who are in "positions of trust" such as teachers and coaches, from having sex with people under their supervision, even if by virtue of age alone, the statutory rape law would not be violated.
You can sometimes be guilty of attempting to commit a crime, or engaging in conduct believing certain facts to be true (as in the case of many child prostitution crimes), but plain vanilla statutory rape crimes are frequently not crimes for which an attempt is cognizable.