The Philadelphia Phillies are preparing a substantial offer to their soon-to-be-free-agent left-hander Cole Hamels in an attempt to determine whether they can sign him to an extension in the next two weeks, sources told ESPN.com on Thursday.

However, the Phillies are aware that in order to retain the winningest pitcher they have developed in the past 40 years, it could require one of the largest contracts in team history.

Both Phillies general manager Ruben Amaro Jr. and Hamels' agent, John Boggs, declined to comment on any aspect of the negotiations.

The market for Hamels has been shaped in the past few months by the five-year, $112.5 million extension signed by San Francisco right-hander Matt Cain in April, a deal that actually guaranteed him six years and $127.5 million when his salary for 2012 was factored in.

The Phillies also influenced that market with the five-year, $120 million deal they agreed to with Cliff Lee in December 2010, a contract that established a then-record average annual value for a pitcher of $24 million per season.

Although the Phillies' payroll is approaching the $178 million luxury-tax threshold (and actually may already have exceeded it), the club believes it can find a way to sign Hamels and stay under the threshold in 2013 and beyond, a source said.

However, the Phillies never have signed a pitcher to a contract that included more than the five guaranteed years they gave Lee. And sources said they remain wary of guaranteeing six years or more, but have had numerous internal discussions about whether to break that precedent in Hamels' case.

Hamels has been a walking trade rumor for weeks. Those rumors have only intensified as the Phillies were careening into the All-Star break with 10 losses in their past 11 games, dropping them 14 games out of first place and 10 out in the wild-card race.

Nevertheless, with Roy Halladay potentially a week from rejoining their rotation, the Phillies have told other teams they will wait as long as possible -- maybe even two more weeks -- before making a decision on whether to sell off players such as Hamels and outfielder Shane Victorino. By then, they hope to have a clearer picture on whether they can sign Hamels long-term before he hits free agency this fall.

There has been no indication the two sides have made any progress toward a new deal for months. However, executives of two clubs that spoke to Phillies' officials say Philadlephia has been expressing a surprising level of optimism it can get the 28-year-old left-hander signed this month.

"They're trying to sign him," said one of those executives. "And they think it's going to happen. At least that's what I was told."

What the Phillies have no way of knowing, for now, is whether Hamels shares their optimism.

During his media availability before the All-Star Game this week, Hamels was at his diplomatic best, saying that even if he reaches free agency this offseason and many teams are bidding on him, he would "always put (the Phillies) at the top of my list."

However, he also sounded intrigued by free agency, saying at one point: "Every human being wants to know what their value is, in whatever job they're doing. If you get to do it, it's a pretty cool experience."

And that, according to one of Hamels' teammates, is no negotiating ploy.

"If Cole has his way," Hamels' friend said, "he'll wait 'till the end of the year, go out there and see what he's worth and then ask the Phillies, 'OK, what do YOU think I'm worth?' "

That's an indication, with free agency only a few months away, the Phillies essentially will have to offer free-agent market dollars -- and years -- if they hope to sign him now. If they can't, they are likely to turn their attention to trading him before the deadline, and then likely making another attempt to sign him in the offseason.

The Texas Rangers have been prominently mentioned as the favorites to trade for Hamels if the Phillies deal him. But other clubs have said privately that while they are interested, they're still biding their time, waiting for signals that the Phillies seriously intend to trade him and that the initial price tag, of four or five premium young players, has come down.

Hamels potentially could appeal to a long list of contenders that could include the Dodgers, Tigers, Pirates, Red Sox, Cardinals and Reds. However, the Phillies won't begin to focus seriously on potential trades until they can determine whether their view of Hamels' market value is in the same ballpark as his.