Put pinto beans in a blender; puree until smooth. Transfer bean puree to a bowl.
Combine cocoa powder, butter, and vanilla extract with bean puree; mix well. Add confectioners' sugar; beat with an electric mixer on high speed until fudge is thoroughly mixed, about 3 minutes. Stir in walnuts.
Spread fudge into the prepared pan. Refrigerate until firm.