Black codes were restrictive laws designed to limit the freedom of African Americans and ensure their availability as a cheap labor force after slavery was abolished during the Civil War
They make a government by the social contract to protect rights that they even had in their state. But remember it was only to protect their rights. But unfortunately they had to break it.