The Messenger of Allah ﷺ said, "Gold for gold, silver for silver, wheat for wheat, barley for barley, dates for dates, and salt for salt, like for like, equal for equal, hand to hand. But if these categories differ, then sell as you wish, provided it is hand to hand."
قال رسول الله ﷺ: الذهب بالذهب، والفضة بالفضة، والبر بالبر، والشعير بالشعير، والتمر بالتمر، والملح بالملح، مثلا بمثل، سواء بسواء، يدا بيد، فإذا اختلفت هذه الأصناف فبيعوا كيف شئتم إذا كان يدا بيد.
Muslim reported it in the Book of Musaqah (1587:81) via Waki, who narrated from Sufyan, from Khalid Haddan, from Abu Qilaba, from Abu Ashath, from Ubada bin Samit, who mentioned it.