The Messenger of Allah ﷺ forbade selling silver for silver or gold for gold except in equal measure, and he commanded us to buy gold with silver however we wished, and silver with gold however we wished.
وفيما قرئ علينا أحمد بن منيع قال حدثنا عباد بن العوام قال حدثنا يحيى بن أبي إسحق قال حدثنا
نهى رسول الله ﷺ عن بيع الفضة بالفضة والذهب بالذهب إلا سواء بسواء وأمرنا أن نبتاع الذهب بالفضة كيف شئنا والفضة بالذهب كيف شئنا
Bukhari narrated it in "Sales," chapter "Selling gold for silver hand to hand," hadith no. 2182, and Muslim narrated it in "Sharecropping," chapter "The prohibition of selling silver for gold on credit," hadith no. 1590, from the hadith of Abbad bin Awwam, through the same chain. It is also in Kubra, hadith no. 6170.