A Scots mastermind of the dark net has admitted dealing drugs for the virtual currency Bitcoin in a landmark conviction for law enforcement agencies.

READ MORE: Bitcoin: the currency of choice for criminals?

David Trail has pled guilty to both supplying Diazepam and hacking credit card details at Edinburgh Sheriff Court.

The 26-year-old IT specialist was brought to justice 18 months after his flat in the capital's Fountainbridge area was raided in an international attack on illicit internet traders co-ordinated by America’s FBI and police from Germany, England and Scotland.

Trail had “constructed and administered” Topix2, a now closed international trading site described as “a criminal eBay of the darkweb”, prosecutors said.

His flat was targeted by Police Scotland’s Cybercrime Unit in November 2014 as police across Europe and America swooped on darknet marketplaces that had sprung up to replace the Silk Road, an Amazon for drug dealers that was taken off line by the FBI a year earlier.

That operation came as global law enforcement, backed by the European Union’s Europol agency and the FBI, increasingly geared up to the challenge of drug dealing, gun-running and other criminality moving online.

Compared by law enforcement sources to the scientific genius Sheldon Cooper of hit US comedy The Big Bang Theory, Trail had some of the most sophisticated computer systems ever seen by Scottish police.

They included customised keyboard with no markings. When police cracked open his computer they found the details of credit cards, including the three-digit security code printed on their reverse, that he had stolen from his former employer, Scotweb.

Picture: David Trail

Detective Inspector Brian Stuart, of Police Scotland’s Cybercrime Unit, said: “There is no doubt that the early intervention of law enforcement prevented Trail from pedalling drugs in his serious and organised criminal enterprise. New and traditional policing technique’s assisted in bringing Trail to justice.

“Following information from colleagues in FBI, West Hessen Police and the UK’s National Crime Agency, Police Scotland identified David Trail and his operation and ownership of a hidden website designed to enable its users to buy and sell illegal drugs anonymously and beyond the reach of law enforcement.

“His targeting of a previous employer overcoming their security almost had a devastating effect on the companies’ ability to remain in business.”

Mr Stuart added: “The conviction of Trail should serve as a reminder to those wishing to involve themselves in criminal enterprises on the internet that there is no hiding place.”

READ MORE: Police Scotland's extra spending on a Cybercrime hub

Picture: sources compare Trail to TV's Sheldon Cooper

The initial investigation in to Trail began in August 2014 when the FBI handed over a range of IP addresses linked to a whole range of darkweb sites – the generic term for hidden servers and vendors used to trade everything from child porn to guns.

The narcotics squad in Hesse identified Trail as the ultimate controller of a website hosted in Germany.

Police Scotland searched his flat in Watson Crescent on November 6 2014. They found what they regarded as a modest stash of Diazepam, 244 tablets, Jiffy bags and stamps. Postal receipts showed Trail had been sending packages to Europe, including Austria.

Screen grabs of Topix2 before its closure show Trail advertising different kinds of Diazepam, which is a legal prescription drug but highly controlled.

One advert shows the pills arranged in to a heart shape. “Standard pharmacy grade Diazepam,” the eBay-style ad says. “ You won’t be disappointed. Offering a few on the cheap to get things rolling.” Another says: “This Valium is produced in the UK and tastes nice when melted in the mouth. Next day delivery free.” He was charging £60 for 100 pills but said “I only accept bitcoin, sorry.”

Images: screengrabs from the Topix2 darknet site

The digital currency - which can be exchanged for some goods and services in the real world - has become popular among criminals.

The raid on Trail's home was one of scores carried out under an international operation initially claimed to have shut down 400 darknet sites such as Topix2.

Trail’s former employers, Scotweb, were sent a list of stolen credit card details in May 2014 by an unknown person. The company did not tell the police but were eventually fined £10,000 by a bank for the data breach. The theft has cost them thousands more to repair and rebuild their online security. The card details were found in Trail’s computer after the raid.

Trail pled guilty to the two charges after a plea agreement. He will be sentenced next month.

This week it also emerged police had raided four addresses in Scotland hosting illegal “Torrent” streaming sites for pirated music, films and games.

Image: Screengrab from Topix2 shows international shipping