Ed Sheeran wants to buy Pharrell Williams a hat to say thanks.

The British hit maker and the Happy singer collaborated on Ed's latest single Sing from second album x, which has bagged Ed his very first number one in the UK.

But if it hadn't been for Pharrell, Ed may not be celebrating chart glory.

"I swear Pharrell has special foresight. I said I wanted to release Don’t as the first single. He said it should be Sing and it would do over 100,000 in the US and sure enough it’s doing 140,000. I owe him a hat or something," Ed laughed to MTV as part of a new documentary about the flame-haired star.

The feature, Nine Days and Nights of Ed Sheeran, follows the 23-year-old singer around, giving fans a rare insight into his life.

Ed also opens up about how top producer Rick Ross turned up at one of his gigs, leading to a weird encounter with one of the most powerful men in music.

"Rick came to my birthday gig and I was dressed as a pirate.

“I was summoned by Elton John to meet him, so it was us and Adele. I felt awkward dressed as a pirate," Ed laughed.

“Six months later he was listening to my album and telling me: ‘You shouldn’t be doing it like this’ or ‘Sing it like this.’”

Ed's musical talents haven't just helped his own career; the talented musician has penned tracks for countless other artists.

In a recent interview, Ed revealed how Simon Cowell had called on his talents once again for super group One Direction.

"I had a night time meeting with Simon Cowell yesterday [Sunday], that's an exclusive," Ed told British radio station Capital FM.

Ed was behind the boys' second number one Little Things in 2012.