The market for medical marijuana and recreational marijuana is growing rapidly, as lawmakers in more states pass legislation legalizing it. Already, 28 states have medical marijuana laws on the books, and eight states have passed recreational marijuana laws, too. According to the latest research by GreenWave Advisors, those numbers are about to climb significantly.

Where marijuana is legal now

Last November's election reshaped the marijuana state map. Ahead of the election, voters in only four states (Alaska, Colorado, Oregon, and Washington) had voted to establish recreational markets for adult use of cannabis, and 24 states had passed medical marijuana laws.

As a result of the election, four more states will open up recreational markets -- California, Maine, Massachusetts, and Nevada. Another four states passed laws allowing medical marijuana, including Florida.

Every state could legalize marijuana soon

GreenWave's founder Matt Karnes thinks that we're on the cusp of a significant increase in the number of states that will pass medical and recreational marijuana laws.

Plans are already underway to get marijuana proposals on ballots in 2018 and 2020, and depending on how those votes go, medical marijuana or recreational marijuana could be legal in all 50 states -- plus D.C. -- in 2021.

Donald Trump and his attorney general, Jeff Sessions, could be key to that prediction's coming true. In the past, the federal government has deferred to the states when it comes to marijuana legalization, but that could change.

On the campaign trail, Donald Trump supported medical marijuana, but he was less than enthusiastic about recreational marijuana. His appointment of Jeff Sessions as the country's top lawyer also creates uncertainty.

Sessions has been a vocal opponent of marijuana, and he may not be willing to continue with a lassez-faire policy when it comes to enforcing federal laws prohibiting marijuana. Recently, he suggested enforcement of federal marijuana laws could intensify, and in a speech in Virginia, he said that marijuana was "only slightly less awful" than heroin.

A lot of money is at stake

States have a lot of incentive to legalize marijuana. According to Karnes, retail sales of marijuana clocked in at $6.5 billion last year, up from $4.8 billion in 2015. That means a lot of money is ending up in state tax coffers.

GreenWave estimates that the marijuana black market is worth $36 billion and that passage of marijuana-friendly laws nationally could lead to $30 billion in marijuana sales in 2021. Based on those assumptions, the potential tailwinds for tax revenue over the next five years should be strong, and that could factor greatly into whether or not pro-pot laws pass.

Ways to invest in marijuana

Investors interested in riding marijuana's momentum to profit don't have many investment options available to them. The majority of pot stocks that investors can buy trade on the unregulated over-the-counter market, and that exposes investors to a significant risk of falling victim to fraud.

Until the marijuana market matures enough for companies to graduate to the more regulated stock exchanges, it may be best to invest in back-door companies that benefit from marijuana's becoming more mainstream.

For example, GW Pharmaceuticals (NASDAQ:GWPH) has been researching marijuana medicine since the 1990s, and it plans on filing soon for FDA approval of its CBD drug -- Epidiolex -- for use in epilepsy patients. If the FDA approves Epidiolex, it can be prescribed by any doctor in the U.S., regardless of whether or not a state has passed pro-pot laws. Because it's estimated that as many as one-third of epilepsy patients are inadequately treated with existing medications, Epidiolex could become a top-seller for the company.

The Scotts Miracle-Gro Company (NYSE:SMG) is another intriguing way to gain exposure to the marijuana market. The company generates 90% of its sales in the United States, and management is forecasting 4% to 5% year-over-year sales growth this fiscal year. Some of that increase is due to rising demand from marijuana growers. Hydroponics has become a major focus for the company, and a series of acquisitions has it well positioned to profit from that market. In 2015, it acquired General Hydroponics for $130 million, and in 2016, it acquired 75% of Gavita, a grow lighting and hardware company, for $136 million. It also acquired Arizona's Botanicare for $93 million, and it has invested in Colorado-based indoor grow company AeroGrow.

Overall, there's a tremendous amount of risk associated with marijuana stocks, and regulation remains a big obstacle to marijuana market expansion, so investors should approach all cannabis stocks with a healthy dose of caution.