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مسند احمد / مسند المكثرين من الصحابة / 13264
Hadith Gradingحکم دارالسلام:حديث صحيح، وهذا إسناد قابل للتحسين لأجل جعفر بن معبد، روى عنه اثنان، وقال أبو حاتم: صالح، وذكره ابن حبان في الثقات