كتاب المساقاة
22  
The Book of Musaqah
(23)
Chapter: The permissibility of selling animals for animals of the same kind and of different quality
(23)
باب جَوَازِ بَيْعِ الْحَيَوَانِ بِالْحَيَوَانِ مِنْ جِنْسِهِ مُتَفَاضِلاً ‏‏
Sahih Muslim 1602

Jabir (Allah be pleased with him) reported:

There came a slave and pledg- ed allegiance to Allah's Apostle (ﷺ) on migration; he (the Holy Prophet) did not know that he was a slave. Then there came his master and demanded him back, whereupon Allah's Apostle (ﷺ) said: Sell him to me. And he bought him for two black slaves, and he did not afterwards take allegiance from anyone until he had asked him whether he was a slave (or a free man)
حَدَّثَنَا يَحْيَى بْنُ يَحْيَى التَّمِيمِيُّ، وَابْنُ، رُمْحٍ قَالاَ أَخْبَرَنَا اللَّيْثُ، ح وَحَدَّثَنِيهِ قُتَيْبَةُ، بْنُ سَعِيدٍ حَدَّثَنَا لَيْثٌ، عَنْ أَبِي الزُّبَيْرِ، عَنْ جَابِرٍ، قَالَ جَاءَ عَبْدٌ فَبَايَعَ النَّبِيَّ صلى الله عليه وسلم عَلَى الْهِجْرَةِ وَلَمْ يَشْعُرْ أَنَّهُ عَبْدٌ فَجَاءَ سَيِّدُهُ يُرِيدُهُ فَقَالَ لَهُ النَّبِيُّ صلى الله عليه وسلم ‏"‏ بِعْنِيهِ ‏"‏ ‏.‏ فَاشْتَرَاهُ بِعَبْدَيْنِ أَسْوَدَيْنِ ثُمَّ لَمْ يُبَايِعْ أَحَدًا بَعْدُ حَتَّى يَسْأَلَهُ ‏"‏ أَعَبْدٌ هُوَ ‏"‏ ‏.‏
Reference : Sahih Muslim 1602
In-book reference : Book 22, Hadith 152
USC-MSA web (English) reference : Book 10, Hadith 3901
  (deprecated numbering scheme)