When you see a creature in range casting a spell using Verbal, Somatic, or Material components, you may try to interrupt it with a Reaction. The target makes a Constitution save. On failure, the spell dissapates, and the the casting Action, Bonus Action or Reaction is wasted. If the spell used a spell slot, it's not expended.
The most valuable ability as a professor in the Royal University is not academic excellence, but quick reflexes.
-Eudoria Hackett, Royal professor
Cast a spell of level 5 or lower that you can cast in an action targeting yourself. This becomes the contingent spell, expending its spell slot as well as Contingency's spell slot. The spell doesn't take effect until a chosen trigger occurs.
As soon as the trigger happens, the spell takes effect whether you want it to or not, and then Contingency ends.
You can only target yourself with the contingent spell, you can only have one contingent spell at a time, and the whole spell ends if you ever don't have the material component on your person.
See the Player's Handbook for the exact rules.
Spells casting spells seems like a bad idea. Let's try it.
-Abjurist Ovtuch Irieya moments before major arcane breakthrough