When Greg Marsh moved to New York City, his wife kept locking herself out of their apartment. “Then she’d wait an hour for a locksmith to charge $150 for two minutes of work,” he says. That got Marsh wondering about the locksmith industry -- which is $7.5 billion and totally fragmented.

He came up with an idea: KeyMe, an app that scans and stores digital copies of keys, which can then be printed at kiosks or ordered by mail. In just four years, he’d go on to raise $31 million of venture capital in three equity rounds. Here’s how he did it.

Marsh knew he needed cofounders with technical skills. He was a Columbia Business School student at the time, so he approached engineering professors and asked to meet their best students. “A series of in-depth conversations later, I had two amazing, skilled cofounders,” he says.

Rather than waste time cold-­emailing VC firms, Marsh went social: “I spent the bulk of my time practicing my pitch with other entrepreneurs in hopes of getting a warm introduction with potential investors.” After about 1,000 iterations of his pitch deck, the plan paid off: Angel investor (and b-school mentor) Ravin Gandhi invested $300,000, which helped the company hire employees away from NASA, Raytheon and Lockheed Martin. Now they were able to spend a year prototyping the first kiosk, which they placed in a Manhattan bodega. It worked. Nine months later, they closed a $2.3 million seed round, and used the funds to build the app and test five more kiosks.

Fifteen months after that, KeyMe began Series A fund-raising. They asked the lead from their seed round, Battery Ventures, which was happy to pitch in again. They hit up 7-Eleven’s investment subsidiary, 7-Ventures -- a natural constituency. And they connected with White Star Capital, which they won over with their technical approach. (“They have NASA engineers and Ph.D.’s on staff!” says White Star Capital managing partner Christian Hernandez Gallardo, now a KeyMe board member.) In April 2014, KeyMe’s Series A closed at $7.8 million. A pattern was forming: Grow the network, grow the business, repeat.

With this new money, KeyMe expanded to 20 states and improved its technology. “Now we have powerful, affordable cameras. Plus, artificial intelligence reduces the error rate,” Marsh says. In January, KeyMe announced a $20 million Series B. It included money from all the company’s previous funders -- plus some new ones, of course.