Prep the chocolate: Melt the chocolate in short bursts in the microwave or over a double boiler.
Stir until smooth, then let it cool to room temperature so it doesn’t melt the butter.
Beat the butter: Add the softened butter to a large mixing bowl. Beat on medium-high for 2–3 minutes until pale and fluffy. Scrape down the bowl.
Add cocoa and vanilla: Mix in the cocoa powder, vanilla, and espresso powder (if using).
Beat on low until combined, then increase to medium for 30 seconds.
Sweeten gradually: Add powdered sugar 1/2 cup at a time on low, mixing just until incorporated. Scrape the bowl often to prevent pockets of sugar.
Loosen and smooth: Add the salt, 2 tablespoons of cream, and the sour cream (if using). Beat on medium until creamy.
If it looks dry, add more cream 1 tablespoon at a time.
Add the melted chocolate: Pour in the cooled melted chocolate. Beat on medium until fully blended and glossy.
Whip it: Increase speed to medium-high and whip for 2–3 minutes until light and airy. Don’t overwhip to the point of looking curdled; stop when it’s fluffy and smooth.
Adjust texture: If too thick, add a splash of cream.
If too soft, add a little more powdered sugar. Taste and adjust salt.
Use or chill: Frost your cake or cupcakes right away, or chill for 10–15 minutes if you want slightly firmer swirls for piping.