Needless to say, if your contract says you’ll be employed for 2 years, there are consequences to firing you before that time is due. You can go over the contract yourself to see if the circumstances of you being fired were above board, or you can get a free consultation from a law firm like https://www.amfllp.com/practice-areas/wrongful-termination/.
Even if your contract stipulates that your employer can fire you at will, they still are not allowed to fire you based solely on your race or gender. You also can’t be fired because of your religion, disability, marital status, for requesting family leave, for becoming pregnant, and more. If you believe you have been fired due to any of these factors, you may have grounds for a wrongful termination suit.