The Messenger of Allah ﷺ forbade sales involving uncertainty and sales decided by the throwing of a pebble.
حدثنا أبو كريب أنبأنا أبو أسامة عن عبيد الله بن عمر عن أبي الزناد عن الأعرج
نهى رسول الله ﷺ عن بيع الغرر وبيع الحصاة
Muslim also narrated it in the Book of Sales, chapter on the invalidity of the pebble sale and sales involving uncertainty, hadith no. 1513, from the hadith of Abu Usama, with the same wording.On this topic there are also narrations from Ibn Umar [Ibn Hibban, hadith no. 1115, and Bayhaqi, 5/338], Ibn Abbas [Ibn Majah, hadith no. 2195], Abu Saeed [he perhaps refers to the hadith of Bukhari, no. 6284, and Muslim, no. 1512], and Anas [Abu Yaala, 5/155, hadith no. 2767, and Bayhaqi, 5/9].