An IT expert caught by the FBI was found to be behind an "Amazon of the dark web", selling drugs across Europe from his Edinburgh flat.

David Trail also obtained credit card details from the accounts of customers while working as a systems administrator for a marketing company.

The 26-year-old's home on Watson Crescent was raided by Police Scotland on November 6, 2014, as part of an international operation involving the FBI and German police forces.

They discovered a site called Topix2 had been run from a server based in Germany which was being rented by Trail.

On Tuesday, fiscal depute Andrew Richardson told Edinburgh Sheriff Court there were vendors selling illegal products on the "dark web" in a similar way to commercial websites such as Amazon and eBay but allowing people to browse anonymously and securely without being monitored.

One of these "dark web" sites was Topix2, the court heard.

Trail was ordered to carry out 200 hours of unpaid work after pleading guilty last month to being concerned in the supply of diazepam between May 1, 2013, and November 6, 2014.

He was also ordered to pay £17,000 compensation to Scotweb having admitted hacking into its computer systems while working there as a systems administrator and web application developer between March 21 and May 9, 2014.

Experts who inspected computer equipment seized from Trail's flat described it as being "among the more advanced in terms of skill required to use it effectively".

Officers also found 244 blue diazepam tablets, envelopes, jiffy bags and stamps along with packaging and postal receipts for various addresses in Europe.

A file called druggers.txt with details of 23 names and addresses was discovered on his computer equipment.

Four people on the list admitted purchasing diazepam from Trail using the website.

Mr Richardson said it had not been possible to quantify the amount of the drug dealt by the accused.

Police also found a list of names and credit card details of Scotweb customers.

The fiscal said this had caused the company "a great deal of inconvenience and considerable expense".

It employed a firm of professional data auditors at a cost of £7000 and was fined £10,000 by its bank for the data breach.

It was also estimated it cost the company thousands of pounds in staffing to try to identify how the breach had occurred, as well as attempting to rebuild its payment and security systems.

Defence solicitor Jennifer Cameron told Sheriff Frank Crowe her client had been suffering stress and anxiety while studying at Edinburgh University.

He could not get tablets from his doctor and had started purchasing diazepam on the internet. To pay for the drug he was using, he started selling small amounts to a few other people.

She said: "His position is he made no financial gain."

Sheriff Crowe said he accepted only small amounts of the drug were involved, and in other cases, that might have resulted in a summary complaint. He added he found the charge involving Scotweb the more serious charge.

He told Trail, who had no previous convictions: "You had a promising career which has been hurt by these crimes.

"You pled guilty at an early stage which avoided a trial and the background report is favourable, and you are at low risk of re-offending."