Preheat your oven to 350°F (175°C).
Lightly grease your 9x9 inch baking pan or line it with parchment paper.
In a medium mixing bowl, whisk together the flour, cocoa powder, baking powder, and salt.
In a large mixing bowl, melt the butter and mix in the sugar. Stir in the vanilla extract and eggs one at a time.
Gradually add the dry mixture to the wet ingredients, folding gently until just combined.
If using, fold in the walnuts gently.
Pour the batter into the prepared baking pan and spread evenly.
Bake for 20-25 minutes, or until a toothpick comes out with a few moist crumbs.
Let cool in the pan for 10 minutes before transferring to a wire rack to cool completely.