The contract is an implicit agreement to form a society - is there any basis for laws about how to treat those outside our society?
I am somewhat uncertain what you refer to when you refer to "the contract" in your question. It occurs to me you could be speaking about "the social contract," but the rest of your question does not seem to imply this. So, I think the best I can do is to address what the social contract is and then move on to address the treatment of "outsiders."
The social contract is a concept originated by Jean-Jacques Rousseau in a book of the same name published in 1762, which, you might notice, predated by only a few years the American Revolution and the French Revolution. Rousseau's book argued against monarchy, which held its power with "divine right," money, and military monopoly. He argued that the power of governance should be vested in the people, who would voluntarily give up some rights and take on some duties, a fair exchange for the good of all in society, as long as rights were equally applied and duties were equally distributed, everyone subject to the rule of law.
I cannot speak for Rousseau, but I suspect he would have argued that once a political entity was created, no one would be an "outsider," so his general ideas do not seem to bear much upon your question. But there is certainly ample precedent for disparate treatment for outsiders in most societies. For example, in ancient times, those conquered in war were often made slaves, and in fact, today, that is happening in areas where ISIS holds sway. In the United States, slavery consisted largely of "outsiders," Africans stolen from their continent. To this day, the descendants of those slaves are still considered "outsiders" to many, sadly, a legacy of the South's attempts to continue a segregated society in which African-Americans, constitutionally full citizens of the United States, were deprived of their rights with Jim Crow laws and also prevented from fulfilling their duties, such as fighting side by side with white soldiers in war or voting. Various police actions we have all seen on video in recent times make clear that for certain "outsiders," the rule of law does not apply. Another kind of precedent can be seen in the treatment of immigrants, both legal and illegal. Neither group is entitled to the full rights of American law, and neither group is expected to fulfill the duties of citizens, such as voting or military action. While I am not all that familiar with the immigration policies of other nations, it is my educated guess that historically or currently the policies are not all that different from those of the United States.
A genuine social contract should ideally ensure that outsiders are not treated differently under a rule of law. This is easy to see when one is speaking of citizens, who may be outsiders for any number of reasons, race, ethnicity, religion, or sexual preference, for example. The case becomes more complicated when the outsiders are not actually citizens, and it is not unreasonable to require that such outsiders "earn" the right to become part of the society. However, if the hurdles to citizenship are too onerous or impossible, then a subclass is created, which surely undermines the social contract.