Elon Musk can thank investors for his staggering net worth of nearly $300 billion. But taxpayers played a crucial role as well. Just how much — or how little — Musk pays in taxes has gotten a lot of attention lately, and even prompted his Twitter poll last weekend that preceded his decision to sell $6.9 billion worth of Tesla stock. There have been calls in Congress for a billionaires’ tax that would require at least some minimal payment from wealthy individuals like Musk who often have little in the way of taxable income. Musk has attacked that idea on Twitter. But just how much of his wealth is due to the government support his companies receive is not an easy question to answer. By some measures, little of his wealth is thanks to taxpayers. And in some ways, virtually all of it is. Musk’s wealth is based on the value of his companies including Tesla\n \n (TSLA), which is only the sixth US company in history to be worth more than $1 trillion, and SpaceX, believed to be the nation’s most valuable privately-held enterprise with an estimated value of more than $100 billion. But those valuations are based mostly on investors’ belief in their future sales and profits, not the relatively modest financial results those companies have shown to date. Tesla sales and earnings, for example, represent a fraction of other long-established automakers. Tesla saw global sales of 627,000 vehicles in the first nine months of this year, and net income of $3.2 billion, both records for the company. But global sales at Toyota were 10 times greater and its net revenue was 2.3 trillion yen, or $20.3 billion, more than six times Tesla’s. Even so Tesla shares more than triple the value of Toyota’s market cap. And Toyota is the world’s second most valuable automaker. Tesla’s market cap is roughly equal to that of the 12 largest automakers in the world combined. Without taxpayer support, however, neither Tesla nor SpaceX would have survived this long, and investors never would have had the chance to make massive bets on both companies. Don’t take our word for it. Ask Musk himself. Billions from regulatory credits In a tweet last year, Musk admitted that Tesla nearly was forced to file for bankruptcy as recently at 2019. The stock price that seems unstoppable today had been floundering among investor’s justified concern that the company was facing a cash crunch as it had difficulty ramping up production of its Model 3 sedan. “Closest we got [to bankruptcy] was about a month ago,” he said in that 2020 tweet. “The Model 3 ramp was extreme stress & pain for a long time — from mid 2017 to mid 2019. Production & logistics hell.” What Musk didn’t say was that one of the keys that kept the company alive was the sale of regulatory credits to other automakers. Environmental regulations require companies that are not meeting emission standards to pay fines or buy credits generated by companies that comply with the rules. And no one had more of those credits to sell than all-electric Tesla. Between 2008 and the first half of 2019, sales of regulatory credits generated more than $2 billion that was crucial to the company’s survival. And the increased car sales ever since have resulted in additional credits that Tesla sold for another $3 billion since June of 2019. That allowed the company to show profits sooner than it would have without the credits, lifting the value of the stock. In fact it wasn’t until the second quarter this year that Tesla reported more in net income than it got from regulatory credit sales. “It was really US taxpayers that helped get him through his roughest time,” said Dan Ives, tech analyst with Wedbush Securities who is a bull on Tesla shares — today. In 2019, he was still skeptical as the company struggled. “If it didn’t have regulatory credits, Tesla would not be the brand it is around the globe, and Musk wouldn’t be the richest person in the world,” Ives said. Other billions for Tesla That wasn’t the only government assistance for Tesla. In January 2010 the company received a $465 million low-interest loan from the Department of Energy, months before its initial public offering when it was still in need of cash. It was able to pay the loan back early, but only through proceeds from an additional sale of stock in 2013. The company also has benefited from the substantial tax credits car buyers receive when they buy a Tesla or other plug-in vehicles. Those tax dollars went to the buyers, and not directly to the company, but the incentive allowed Tesla to charge more for its cars than it otherwise could. In fact when the $7,500 federal tax credit on Tesla purchases was halved to $3,750 in early 2019, Tesla responded by cutting the price of its cars by $2,000 to remain competitive. Tesla buyers received total federal tax credits worth an estimated $3.4 billion before the perk disappeared entirely at the end of 2019. Even if that only allowed Tesla to raise prices by half that amount, that’s another $1.7 billion in federal help, on top of the $5 billion it has received— so far — from regulatory credit sales. NASA saves SpaceX And then there’s SpaceX, which is a smaller but still significant source of Musk’s wealth. The taxpayer support for this venture is even more clear, since it comes in the form of direct government contracts that are worth billions. According to Sam.gov, the government database that tracks federal spending, Space X has signed contracts worth nearly $10 billion. None was more crucial than the one the company received just before Christmas in 2008, when Space X and Musk were both virtually out of cash. That contract to fly 12 supply missions to the International Space Station was worth $1.6 billion. The deal was crucial because it allowed the company to complete work on its Falcon 9 rocket, its main workhorse, as well as the Dragon capsule that would carry supplies and eventually crew, said Casey Dreier, senior space policy advisory for the Planetary Society, a public interest group advocating space flight. “They were right on the edge of insolvency,” Dreier said. “Elon has pointed out at that moment they were on the edge and that helped to save the company.” Dreier said the ISS and other contracts have worked out well for NASA, too, allowing the agency to use SpaceX rather than relying on the Russians to transport US astronauts. SpaceX has since gotten numerous additional government contracts from NASA, the military and other US government agencies. It won a $3 billion contract to develop the next vehicle to carry astronauts to the surface of the moon. And Dreier said SpaceX and other NASA contractors also benefit from the agency’s in-kind support, including access to NASA employees and expertise. – CNN Business’ Jackie Wattles contributed to this report.