Wearing a straw hat and a big grin, farmer Casey O’Neill is busy greeting customers at a Saturday farmers’ market in Mendocino County, Northern California. “Another day in paradise,” he calls out, as one approaches. Fresh broccoli, courgettes and spring onions are on display on his table, all grown at his farm.

Next to the vegetables is a different kind of crop: mason jars full of marijuana buds, bearing handwritten labels such as “Lemon OG” and “Ogre Berry”. A bong sits at the front of the table, for sampling. “Wow, is that really grown outdoors?” says one shopper who takes a hit. Cannabis-infused honey, lip balm and chai tea are for sale at nearby stands.

Among the market-goers is a bright-eyed entrepreneur, Michael Steinmetz, a native of Venezuela based in San Francisco. He chats with farmers and shows around new staff members, who wear green T-shirts displaying the name of his company, Flow Kana.

The concept behind Flow Kana is simple: delivering farm-to-table cannabis that is organic and grown outdoors. Several of its partner farmers are at the market. When a Flow Kana customer orders some of O’Neill’s Ogre Berry strain, the buds will arrive at their door with a little label saying, “Grown by Amber & Casey”.

Steinmetz says that as cannabis moves out of the black market, customers want to know more about it. “The next step in the evolution of the industry is to know where it is coming from — who grew it, where they grew it and how they grew it,” he says. Using the term “cannabis”, the scientific name for the plant genus, is part of that evolution too, he says, because it doesn’t have the negative connotations of “marijuana” or “weed”.

We want more regulation’, including appellations, licensing and a cap on farm size to keep mega-farms at bay

Silicon Valley lies 300km south of the farmers’ market but its presence is clearly felt. Marijuana is the latest craze to sweep through the tech world, as entrepreneurs and investors look to cannabis to be the next big thing. Legalisation is in place in four states and the District of Columbia, while a further 19 states have legalised medical marijuana, even while it remains illegal at the federal level. California is already the biggest medical marijuana market in the country, and the line has blurred between medical and recreational users because medical recommendations are easy for anyone to obtain. The state is expected to vote next year on a referendum that would fully legalise it for recreational use.

“I definitely feel a sense of urgency, because 2016 is right around the corner,” says Steinmetz, referring to the referendum. “All these cannabis start-ups are popping up everywhere.”

A similar phenomenon swept across other states that have legalised, particularly Colorado, which became the first state to legalise recreational marijuana in 2014. Cannabis start-ups proliferated, from edibles manufacturers to advertising companies to tourism. Enthusiasts from across the US swarmed in.

The Silicon Valley version of that “green rush” looks a little different. It involves slick apps, software and founders who talk about big data and algorithms. AngelList, a website where micro start-ups can look for angel investors, lists more than 300 marijuana start-ups in the US — half were founded this year, and a third of those are in California. (Examples include an Amazon for cannabis, a Kickstarter for cannabis, inventory management software and dozens of delivery companies.) Investments in marijuana-related companies have reached $200m over the past 12 months, quadruple the levels of the previous year, according to CB Insights, a venture capital database.

All these cannabis start-ups are popping up everywhere . . . You have to have a little bit of “street” in you to be in the cannabis business

This rush of funding has attracted software engineers such as Austin Heap, a veteran of some half-dozen start-ups. Heap didn’t initially know much about the marijuana industry, other than being a medical marijuana consumer himself. He and a friend (now co-founder) started batting ideas about last autumn and came up with Potbox, a monthly subscription delivery service for organic, farm-to-table cannabis. They met their other co-founder, a 20-year veteran of the industry, because they had been using his marijuana delivery service.

“It feels like a very normal start-up, it just happens to be cannabis,” Heap told me, the day before their launch on July 8. Later that night, he would put the final touches on their social media accounts and website. “Hopefully at about 2:30 in the morning I will be a) still awake and b) getting Cloudflare in place, which will help us deal with any huge spikes in traffic,” he explained with a geeky enthusiasm. “I’m largely tech focused.” Heap says the huge investor interest in cannabis is “refreshing” after years of doing the venture capital dog-and-pony show. “No start-up I’ve worked on has said no to so many investment requests. I think we have something the cannabis industry has never seen.”

Investments in marijuana-related companies have reached $200m over the past 12 months, quadruple the levels of the previous year

That is a bold claim, given the recent proliferation of cannabis start-ups. Like any hot sector in Silicon Valley, the space quickly gets crowded, especially for delivery companies. As they compete for market share, it becomes a race to get the most funding.

The fundraising king of delivery start-ups is Eaze, which styles itself the “Uber for pot”. Launched a year ago, Eaze already delivers marijuana in 60 cities across California and is eyeing expansion to other states. With a touch of Silicon Valley panache, founder Keith McCarty makes frequent comparisons to Uber when he talks about Eaze’s growth. “We have all the pieces in the puzzle to be the fastest-growing tech company in the world,” he says. “It is like a rocket ship on top of a rocket ship.”

For Eaze’s investors, the delivery platform is a familiar way to get into an unfamiliar sector. DCM Ventures, a venture capital firm located on Menlo Park’s prestigious Sand Hill Road, led Eaze’s $10m fundraising round in April — the first time it had invested in the cannabis industry. “It is pretty clear that the sentiment in this country is changing toward cannabis,” says David Chao, a partner at DCM. “We think that most of the states will probably legalise within the next decade, and most of the populous states will legalise even sooner.”

It feels like a very normal start-up, it just happens to be cannabis

When Chao first floated the idea of investing in Eaze with his partners, it took some convincing. “I really had to brief a lot of the people about the changing landscape,” he recalls. “I explained that what Eaze is doing is 100 per cent legal, no different than getting a prescription from a doctor.” After the deal was announced, however, he says the response has been very positive.

On paper, Eaze does not actually sell marijuana — technically it is a software service that connects customers with dispensaries, a structure that is common among marijuana start-ups. When a customer places an order, the driver who arrives works for a dispensary, and customers pay them in cash. This goes back to the dispensary, which then pays Eaze a lead generation fee. “We thought about how do we create a service that limits our risk,” McCarty explains. “We are a technology service provider. We don’t touch the plant.”

We have all the pieces in the puzzle to be the fastest-growing tech company in the world

McCarty sees giveaway programmes and paid promoters as key. New customers get their first order free and existing customers get a $10 credit for every friend who signs up. Eaze also pays about 10,000 ambassadors to promote the service, $10 per referral. “Nobody else has a street team like us giving out free weed,” McCarty grins. “I’m like, ‘Deploy the troops!’” he jokes, gesturing to his colleague, Jamie Feaster, head of marketing. “And he deploys the troops.”

Feaster says the programme is part of building a community around the brand. He shows me a list of Eaze’s top 10 grossing ambassadors (the top performer has earned more than $4,000). He proudly explains that several of them are either homeless or recently got housing after they started earning money through Eaze. “We have a large collection of people that we found, and enabled, empowered them really, to make money by spreading the Eaze message,” he says.

Eaze has its eye on far more than the delivery market. In June it launched a new app for medical marijuana recommendations. Would-be patients can use their smartphones to video chat with a team of doctors (available seven days a week) and get a recommendation in minutes. The cost, at $25, is half what it would be at most marijuana clinics. Eaze is also building its own rating algorithm that gathers data about which customers like which products, and tweaks menus accordingly. “Being data-driven is something we understand very well,” McCarty says. “Inherently, that is something that you have to do if you are in Silicon Valley.”

Though not a marijuana consumer himself, McCarty feels he has chosen the right sector. “It’s a money train. It is amazing,” he says. “This is not a bubble. This is technology being taken into new industries.”

Eaze is building its own rating algorithm that gathers data about which customers like which products, and tweaks menus accordingly

Despite all the hype, investing in cannabis is not for the faint of heart. Marijuana is still illegal at the federal level — it falls under the most stringent drug classification, along with heroin, Ecstasy and LSD. However, the federal ban is not actually enforced in states where medical marijuana is legal and, in December, Congress passed a bill that protects states’ medical marijuana programmes.

Nevertheless, the ban creates plenty of problems. Almost no banks will allow cannabis businesses to open accounts, fearing federal repercussions. As a result, marijuana has remained a cash-based industry. In Mendocino County, farmers bury their cash in jars under the ground. In Colorado, dispensaries and growers hire armed guards and stack cash in safety deposit boxes. A marijuana banking amendment is winding through Congress but has not passed yet.

There are tech challenges too, such as getting approval from Apple’s app store for marijuana-related apps. (Even Eaze does not actually have an iPhone app available in the store — it uses a web app instead.) And cannabis start-ups often adopt creative corporate structures to try to limit their liability. “You have to have a little bit of ‘street’ in you to be in the cannabis business,” says Steinmetz of Flow Kana. He picked up his street smarts while founding two companies in his native Venezuela, he explains. “Compared to doing business in Venezuela, this is easy.”

19: Number of US states that have legalised medical marijuana; four have fully legalised

In addition to the federal ban, the tangle of local laws that regulate marijuana is complex and often vague. At Eaze, McCarty shows me a giant spreadsheet: cities in southern California have been carefully colour-coded according to how friendly their laws are for cannabis delivery. “The rules and regulations that each place decides to have are just all over the place, and it is extremely difficult for anyone to make sense of it,” says Luke Stanton, a lawyer who advised Eaze as it expanded to new cities. This keeps the market fragmented.

Nevertheless, investors have become bolder after some high-profile deals that have made cannabis investing more mainstream. Earlier this year Founders Fund, a venture capital firm co-founded by Peter Thiel, participated in a $75m investment round into Privateer, a private equity group focused on cannabis*. It is the biggest single investment in the US cannabis industry to date.

The founder of Privateer, Brendan Kennedy, cut his chops in Silicon Valley, first as a founder and then at Silicon Valley Bank. When he began looking at the cannabis industry five years ago, his original thesis was to start a venture capital firm. But he was disappointed with the quality of the businesses — a common complaint among marijuana investors. “What we saw was a mess,” he recalls. “There were no industry leaders, no standards, it was very fragmented . . . We couldn’t find anyone we would trust our money with.” He decided a more hands-on approach was needed and moved to Seattle, where cannabis is fully legal, to start Privateer.

As a private equity company, Privateer founds, incubates, acquires and invests in cannabis companies globally. “I’m always looking at where will be the next place that will legalise,” Kennedy says. In Canada, where marijuana is legal for medical use, Privateer owns Tilray, which grows marijuana under a federal licence. In Jamaica, Privateer is helping conduct genetic research on plant strains. In Uruguay, where cannabis is fully legal, it has applied for a cultivation licence. And in the US (and possibly other countries), it will soon be launching a cannabis brand, Marley Natural, in conjunction with Bob Marley’s descendants.

Kennedy believes the crop is becoming commoditised and that brands will be the valuable part of the industry. “I want growers to grow it, and I want to buy a standard product from them,” he says. He’s dismissive of the idea that some cannabis is better than others. “I’ve met so many people who tell me they grow the best cannabis,” he says sceptically. “But I don’t meet farmers who tell me they grow the best broccoli.”

Everything in this industry is harder, whether it’s hiring a lawyer, an accountant or a PR. I’ve had 23 banks tell us no

Geoff Lewis, the partner at Founders Fund who led its investment in Privateer, sees its focus on branding as a strength. “A lot of the activity in the cannabis market is focused on dispensaries or grow operations,” he says. When he started looking for cannabis investments, he — like Kennedy — found many of the businesses unimpressive. But that changed when he met Privateer. “What Privateer is doing is looking like a Procter & Gamble or a Coca-Cola approach,” Lewis says. “The real value in the market is going to be having the Coke-calibre brand.”

Even as a relative giant in the industry, Privateer has faced plenty of challenges. “Everything in this industry is harder, whether it is hiring a lawyer, or an accountant, or a PR,” Kennedy says. Banking is tough too. “I’ve had 23 banks tell us no, and we’ve been kicked out of several banks, one after 16 months.”

There have also been miscalculations. After investing $25m in its Canadian cultivation company Tilray, Privateer announced lay-offs of 61 staff there in June. Kennedy says risks are inherent in the industry — and that his investors understand this. “This is the riskiest, craziest investment there is. This is not your 401k [a US pension account], this is your crazy money.”

Kennedy recalls one “scary” meeting at a Starbucks in Portland, where he met with a man who had contacted him on LinkedIn. “He slid his card across the table, and it said DEA [Drug Enforcement Agency],” Kennedy says. “My heart rate rose a bit. Then he slid this white envelope across the table and I thought, ‘What have I done?’ But it turned out to be his résumé.” The man had spent most of his career as a drug-busting special agent. Now he is Privateer’s general counsel.

Other cannabis-focused investment funds have also been gaining momentum, although none has achieved the scale of Privateer. ArcView Group, a network that pairs individual investors and entrepreneurs, has facilitated $20m in investments. Funds such as Emerald Ocean Capital and High Times Growth Fund launched in 2013 and 2014 respectively but do not disclose how much they have raised.

Businesses in other industries are also starting to dip their toes in. In April, Scott’s Miracle-Gro, a well-known US fertiliser company, acquired a cannabis fertiliser company, General Hydroponics, through a subsidiary. Hemp, a type of non-psychoactive cannabis that produces fibres and oils, has also seen growing investment as restrictions on hemp cultivation loosen.

The marijuana movement in California has historically been associated with hippie culture. But among the recent wave of start-ups, many are focused on something else: the health benefits. McCarty, the Eaze founder, said the medical benefits of marijuana were one of the first things he researched when considering the sector. “I needed to get behind the mission, behind this not being just a glorified drug-dealing service,” he recalls.

Meadow, another delivery service, recently launched an online guide to the medical uses of marijuana, complete with cute animations. States with medical marijuana programmes allow its use in connection with conditions as diverse as glaucoma, anorexia, cancer, Aids, psoriasis and PTSD. The list goes on and varies by state. Under California’s system, medical marijuana clinics are abundant and are generally happy to hand out recommendation letters to patients with a range of ailments.

But the health impact is hotly contested. The federal restrictions on marijuana make serious academic studies of the drug difficult in the US. Two recent articles in the Journal of the American Medical Association reviewed other studies of marijuana and marijuana extracts, and found good evidence that marijuana and some extracts could help with chronic pain and spasticity. But the study found only low-quality evidence that marijuana helps with other conditions such as sleep disorders or nausea caused by chemotherapy. One big area of concern is the impact that marijuana can have on teenagers’ developing brains.

Many cannabis start-up founders also cite a social mission as part of their reason for working in the industry, on the grounds that legalisation would prevent needless imprisonment for possession. The US has the largest per capita prison population in the world, partly due to harsh drug sentencing.

Amanda Reiman, a marijuana policy specialist who is helping draft the legalisation proposition that is expected to go to referendum next year, says this is one area where the cliché about Silicon Valley making the world a better place holds true. “Usually it’s like this joke,” she says. “But this is an opportunity to make sure that it is actually making the world a better place.”

Altruism aside, the outcome of California’s referendum is not guaranteed. A 2010 attempt failed narrowly, after vocal opposition from the Obama administration. But this one could fare better — last year, the California Democratic party, which holds a majority in the state, added marijuana legalisation to its party platform.

300: Marijuana start-ups in the US; half were founded this year and a third of those are in California

Meanwhile, a distinctly California-style backlash is already growing against the idea of “big pot”, such as that envisioned by Privateer and Eaze. At the farmers’ market in Mendocino, farmers are concerned about the prospect of large commercial cannabis operations that could wipe out the small farms — and they are getting organised to make sure that doesn’t happen.

Flow Kana sees supporting small farmers as part of its goal. “Our mission is to keep cannabis in the hands of small farmers,” says Steinmetz, the founder. The black market fostered a culture where people simply took whatever they could get without asking where it was from, he explains. To help educate consumers, Flow Kana hosts a series of “Meet Your Farmer” soirées, where guests sample “tastings” of different strains.

At one such event in June, in San Francisco, the farmers seem just as delighted as the partygoers. “Look where we are, look at what we are doing, look at what we are talking about,” says a Mendocino cannabis farmer who goes by his yogic name, Swami Chaitanya. “The attitude toward cannabis has really changed.”

Swami’s farm is in the mountains, at the heart of the prime cannabis-growing region known as the Emerald Triangle. This covers an area slightly smaller than Belgium and is thought to supply about half the cannabis in the US. The area’s climate, elevation and sunshine make it ideal for growing cannabis outdoors.

Swami estimates that the annual cannabis crop in Mendocino is worth between $2.6bn and $5.4bn at wholesale prices, a lifeline for the farmers. “It is the last refuge of the family farm,” he says. “You go into the wilderness, you work hard and you come back with your crop. In some crazy way it is the American dream.” No one knows exactly how much weed is grown in the Emerald Triangle but he cites a sheriff’s testimony from 2010 that implied some five million plants in Mendocino County alone.

You go into the wilderness, you work hard and you come back with your crop. In some crazy way it is the American dream

For years, the mountainous terrain of Mendocino also made it ideal for hiding crops, but today farmers are coming into the open far from the eyes of enforcement authorities. Today the county uses drones to monitor marijuana crops and farmers are coming into the open.

Casey O’Neill is acting chair of the Emerald Growers Association, which represents cannabis farmers in the Emerald Triangle. Among the changes he proposes is the introduction of appellations for cannabis-growing regions and a tiered business licensing system for cannabis farms, which would include a hard cap on maximum farm size, preventing mega-farms.

Raids on cannabis farms are still not uncommon in Mendocino, ostensibly to enforce county rules on plant limits, water use and plant location. These are typically carried out by armed convoys that slash plants and seize cash. “That’s why we want more regulation,” O’Neill says. “I’d rather have someone show up with a clipboard and a government sedan.”

As cannabis moves from the underworld into daylight, the process is hardly conflict free. While states legalise, entrenched interests fight to maintain their grip on a system from which they have long profited. Whether it is doctors with lucrative medical marijuana practices, or dispensaries that don’t want competition, legalisation has a way of pitting the old guard against the new.

This is true for drug cartels as well. The US has been an importer of illegal cannabis from Mexico for years but recently the flow has reversed direction. The Drug Enforcement Agency said in December that the US has become an exporter of illegal cannabis to Mexico, as cultivation in the US has increased.

The recent influx of investment has heightened the faultlines in the industry. At Eaze, Collin Lam, whose job is to find dispensary partners, says he often sees a clash between the new entrants and the incumbents. “The old school have been in the business a long time and are making a lot of money,” he says. “They want to stay underground.” As head of expansion, Lam’s job is to vet potential dispensary partners, and figure out whether they are “old school or new school”.

Sometimes the new and the old can find common ground, as they have in Flow Kana or Potbox. The farmers say they get good prices from Steinmetz — there is no middleman — and investors seem willing to support him too. After initially raising $500,000 to launch the company earlier this year, he is currently closing a $2m-$3m fundraising round.

Still, he sometimes gripes about what he sees as Silicon Valley’s short-term view of the world, and how this impacts the cannabis industry. “The Valley is just really interested in growth, and that is all they care about,” he says. He’s not too worried about his competition, however. “Cannabis is going to be so huge, there’s going to be a McDonald’s and a Whole Foods. Eaze is going to be more like McDonald’s. We’ll be more like Whole Foods.”

Leslie Hook is an FT San Francisco correspondent

Photographs: Carlos Chavarría

* This article has been amended from the original to indicate that Founders Fund participated in, rather than led, the investment round.