It was narrated that Ibn 'Abbas said:
"When the Prophet (ﷺ) came (to Al-Madinah), they used to pay in advance for dates, two or three years in advance. He said: 'Whoever pays in advance for dates, let him pay for a known amount or a known weight, to be delivered at a known time.'" (ID)
English reference (ID): Vol. 3, Book 12, Hadith 2280 (ID)
Arabic reference (ID): Book 12, Hadith 2366 (ID)