So when a friend told him about a 12-week program in San Francisco that would pay him up to $40 a week just to stay clean, he decided it was just what he needed.

For five weeks since, he has trekked to a clinic several times a week to submit a urine sample and pick up a few dollars for testing negative.

“What appealed to me was the positiveness of it,” he said. “It is a motivation. Stay off drugs and get some benefits out of it. Why not give it a try?”

The idea of paying people to stay clean has caught on across the country amid a growing body of research indicating that the practice can help keep addicts off drugs.

Smokers in a two-year study at the University of Florida can get vouchers redeemable at Target, Wal-Mart or Amazon.com if tests on whether they have had cigarettes show negative results.

A study of 415 cocaine and methamphetamine users published in October in the Archives of General Psychiatry found that they stayed in treatment longer if they had a chance to win a prize.

Lisa A. Marsch, a researcher with the National Development and Research Institutes, runs a program at St. Luke’s-Roosevelt Hospital Center in New York that offers teenagers medication, counseling and reward vouchers for testing clean for drugs such as heroin.

“It can be a very powerful technique,” she said. “If it increases their motivation to stay clean even a little, it’s worth doing.”

Teens in Miss Marsch’s program must submit three urine samples a week. Pass, and the patient gets a voucher that can be used to buy something. The amounts start small but rise with every clean result. The second test might be worth $3.75, the third, $5. A person who remains drug-free for two months could earn as much as $596 in all.

If past research is a guide, teens getting the vouchers will stay clean at rates roughly 20 percent to 30 percent higher than if they had only counseling and medication, Miss Marsch said.

Nancy Petry, a researcher at the University of Connecticut School of Medicine, conducted several studies in which a clean urine sample earned addicts a chance to win prizes — a bus token, a pair of socks, new dishes, movie tickets. And somewhere in the bowl was a jumbo prize worth about $100.

“It turned out to be a big incentive,” Miss Petry said of her experiments, which have involved about 1,000 people.

Typically, 20 percent to 30 percent of patients might complete a full 12-week treatment course without failing a test, but with the prize system in place, that rate improved to between 40 percent and 60 percent, Miss Petry said.

It is not clear how successful such programs are in the long term. Almost all patients eventually have at least one relapse.