The contract theory of patents