Elon Musk has won. The Tesla CEO made a bet that he could install the world’s biggest battery in South Australia within 100 days, and the whole installation would be free if the company failed. On Thursday, it was revealed that the project has been completed with 46 days to spare.

“Congratulations to the Tesla crew and South Australian authorities who worked so hard to get this manufactured and installed in record time!” Musk said on his Twitter page Thursday.

The batteries are designed to provide reliable power to a part of Australia that desperately needs it. South Australia has dealt with 18 months of blackouts. A 50-year storm event in September 2016 knocked out pretty much the entire state’s electric grid, prompting the South Australian government to invest about $400 million in American dollars in renewable energy technology that should be able to survive storms.

The idea for the battery grid is it will provide up to 129 megawatt-hours of energy on demand when South Australia needs it. That stored energy would give the state time to get other generators powered up and working, preventing the total loss of power in the event of blackout. It’s the world’s biggest backup, basically.

Tesla beat out about 90 other proposals and four serious rival bids to build the battery grid. The company won the contract in July and was about halfway through building the batteries when it officially signed the 100-day contract on September 30.

The site of the wind farm and the Tesla batteries. Google Maps

The Powerpack system provides 100 megawatts of storage to renewable energy firm Neoen’s Hornsdale wind farm near Jamestown in South Australia, which holds enough power for 30,000 homes. The two companies will join engineering company Consolidated Power Projects and state premier Jay Weatherill next week to officially unveil the battery.

“The world’s largest lithium-ion battery will be an important part of our energy mix and it sends the clearest message that South Australia will be a leader in renewable energy with battery storage,” Weatherill told the Associated Press.

Tesla originally first set itself the 100-day goal after a discussion between Musk and Australian software billionaire Mike Cannon-Brookes. In March, Cannon-Brookes asked if Lyndon Rive, Tesla’s vice-president for energy products, was telling the truth when he said the company could install between 100 to 300 megawatt-hours of storage in 100 days.

This set off a bidding process where the state government agreed to fund $113 million of battery storage, a contract Tesla won a few months later.

Of course, Musk was a bit sly with the deadline. Tesla started counting down 54 days ago from September 30, the point at which the Australian energy regulator gave clearance to the project. The company was building the battery for a while prior to this. The project came well under the January 8, 2018 deadline, but Tesla did not build a battery in under two months.

Between now and next week’s unveiling, the battery will undergo a series of checks to ensure it meets state and energy regulations.