I'm not sure it's legal to refuse cash in the U.S., but I still can't remember the last time I used it anywhere but a pop-up food stand.
Where folks get confused is that it is a legal requirement for you to accept cash if I'm settling a debt with you. If you were to run up a $50 bill at the gas pump, then go in to pay with your $50 bill they'd be forced to accept it or let you walk. Trying to convince a cop of that may not be the easiest thing in the world though...
https://www.treasury.gov/resource-center/faqs/Currency/Pages...