Preheat oven to 180 degrees C. Grease a 20x20cm baking pan.
Melt butter in medium saucepan. Remove from heat and stir in sugar and cocoa. Beat in the eggs one at a time, then stir in the vanilla. Combine the flour, baking powder and salt; stir into the chocolate mixture until just blended. Fold in walnuts if desired. Spread the batter evenly into the prepared pan.
Bake for 25 minutes in the preheated oven, or until a wooden toothpick inserted into the centre comes out clean. Cool in pan on a wire rack.