New York CNN Business —  

Canopy Growth, the Canadian cannabis company backed by Corona owner Constellation Brands (STZ), announced plans Thursday to buy US cannabis firm Acreage Holdings.

But there’s a catch.

Canopy (CGC) said that it intends to buy Acreage (ACRGF) “at such time as cannabis production and sale becomes federally legal in the United States.” Many states have legalized the sale and use of marijuana for recreational and/or medical use, but cannabis is still banned on a federal level.

Canopy said Thursday that it was paying Acreage $300 million upfront, and that the total deal will be worth $3.4 billion. But Canopy won’t actually complete the transaction unless cannabis is legalized in America.

The companies said they will continue to operate independently as long as cannabis remains illegal federally in the United States.

Shares of Canopy shot up nearly 8%, while Acreage’s stock rose more than 5%.

Acreage is headquartered in New York and has former US House Speaker John Boehner on its board. Canopy recently brought on Martha Stewart as an adviser to help develop products derived from cannabis for people and animals.

Canopy also made a big bet on hemp and CBD products following the passage of the Farm Bill in the United States at the end of last year. The Farm Bill legalized hemp production.

The company announced earlier this year that it received a license from New York state, where Constellation Brands is based, to process and produce hemp.

That will allow it to develop products that contain CBD, the non-psychoactive compound that some say helps reduce anxiety and stress. The CBD derived from hemp has extremely low levels of THC, the component of marijuana that gets you high.

And Acreage has created a lot of buzz due to Boehner’s involvement with the company. The company also tried to buy a Super Bowl ad earlier this year, but it was rejected by CBS.