The price of gunpowder varied in the Middle Ages due to factors such as the availability of ingredients, demand, and transportation costs. There are recorded instances of gunpowder costing as much as gold. For example, in the 13th century, an Arab manuscript mentioned the price of gunpowder to be 1 dinar per 2 grams, which was equivalent to the value of gold. In comparison, the price of wheat fluctuated between 0.5 and 2.5 dinars per 160 grams during that time.
However, it's worth noting that the early forms of gunpowder were not as potent and stable as the later versions developed in China during the 16th century. The production methods were also less efficient, leading to higher production costs. As gunpowder technology advanced and became more widespread, the price likely became more affordable, especially with increased demand from military applications and the growth of the gunpowder industry.