There isn't a single answer to this question. The most iconic riffs in guitar history have been written in many keys, including F#, E, A, D, G, and others.
That said, there are some things that most popular rock riffs have in common. Most of the most famous riffs for guitar use the pentatonic minor scale (in various keys). Another feature of many iconic riffs is the use of open strings. The E, A, and D strings are the most common ones used in riffs that use open strings.
To write a powerful rock riff, learn your scales, particularly the pentatonic minor scale. Learn to play riffs from songs that you love that you want to emulate. Try changing your favorite riffs slightly to see how changing them makes them better or worse. Start working with your knowledge of the scale and other riffs to come up with ideas.
Of course your first ideas are likely to be not as good as you'd like. Just like learning to play, learning to write takes practice. Keep coming up with riffs and refining them, changing them, writing them down or recording them. Give yourself time and you'll find that you can channel your love of guitar and unlock your creativity. There's no shortcut, but with time you will definitely achieve your writing goals.
Allan Y.
Excellent advice here. A huge part of coming up with your own (riff) writing style is to emulate others. Keep this in mind though: Copy from one , it's plagiarism, copy from many, it's research.04/24/23