It is narrated from Hazrat Anas (may Allah be pleased with him) that when we used to pledge allegiance to the Prophet (peace and blessings be upon him), the Prophet (peace and blessings be upon him) would include the condition "according to ability" in it.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 14025
Hadith Gradingحکم دارالسلام:حديث صحيح، وهذا إسناد محتمل للتحسين لأجل جعفر بن معبد، روى عنه اثنان، وقال أبو حاتم: صالح، وذكره ابن حبان فى الثقات