To unlock your iPhone from its carrier, you'll likely need to contact your carrier directly to cancel your contract.
You can activate a new or used iPhone for use with a cellular service provider in a few steps. Here's how to activate any iPhone, or troubleshoot it.