The Social contract with endogenous sentiments