You need to be independent to get a charter code. Build up your tech so you can build the government buildings that create the civics resource. Takes 250k civics to become independent so it will help to build up your colony to support a lot colonists and have lots of those buildings or be patient and let it build up over time.