A United States lottery ticket from 1776. PHAS/UIG/Getty Images

For early American settlers, buying a lottery ticket wasn’t just a vice or a guilty pleasure—it was a colonist’s civic duty. That’s because lotteries were one of the biggest ways that the 13 colonies supported themselves financially. In the 17th and 18th centuries, the colonies used lotteries to fund libraries, churches and colleges, and even tried to use them to fund the American Revolution.

Lotteries were a part of British settlements in American from the very beginning. In 1612, the Virginia Company of London held a lottery to fund ships bound for the Jamestown Colony. The prize was 4,000 crowns, a good amount of money in those days. Even so, the company wasn’t very successful at selling tickets in London.

In 1616, the company sent people on the road to sell tickets in “instant” lotteries outside of the capital. In these small-scale games, people could find out if they won a prize immediately after buying a ticket, similarly to scratch-and-win lotteries today.

“To put an incorruptible face on the drawings, they made sure that a child drew the lots from the drums,” writes Matthew Sweeney in The Lottery Wars. These “instant” games were a huge success. Over the next four years, they brought in an estimated £29,000—nearly £8 million today, according to the Bank of England’s inflation calculator.

As more colonies settled in the Americas, they also funded their settlements with lottery money. Lotteries paid for public buildings, roads and canals. Influential figures like George Washington, Benjamin Franklin and John Hancock sponsored lotteries for specific projects.

Lotteries also funded some of the United States’ earliest and most prestigious colleges, such as Harvard (1636), William and Mary (1693), Yale (1701) and Princeton (1746). Still, these lotteries didn’t do all of the work. The free labor of enslaved black people significantly drove down the price of construction and maintenance.

Scholars have characterized these lotteries in the colonies as a kind of voluntary tax that colonists paid in exchange for the chance to win prizes. Unlike the Virginia Company’s first lottery, prizes weren’t always in the form of cold, hard coin. A 1720 lottery ad in the Philadelphia newspaper American Weekly Mercury promised the winner “A new brick house, corner of Third and Arch.” Tickets to win the house were 20 shillings each.

In 1776, the First Continental Congress started a huge lottery to help fund the ongoing Revolutionary War. This time, it wasn’t dealing in British pounds, shillings and crowns: it was using Continental Currency, a new form of money specific to the 13 colonies that the congress had introduced the year before. Because the new currency’s value was fluctuating so widely, the lottery wasn’t able to earn much, and it ended up being a total bust (they still won the war, but they needed help from the French).

Lotteries remained popular in the the early U.S. after the revolution, and the new states continued to use lotteries to fund projects as they had as colonies. Since then, lotteries have gone in and out of public favor, but have continued to be a lucrative business.