The legislation follows multiple fentanyl overdoses of teenagers who bought pills on encrypted apps.