Over the last couple of decades, coffee has gone from being a plain, watery drink to an often-luxury staple available in endless combinations. You can now pay an incredible $18 for a single cup in Brooklyn . And millennials are said to be more discerning about quality, origin, and preparation than their predecessors. Sales of espresso-type coffee have tripled since 2008, driven largely by younger tastes, the National Coffee Association says.

This discernment, while sometimes annoying, does have the benefit of producing changes in the wider supply chain. The “premiumization” of coffee pays for accreditation standards, greater traceability, and investments in enabling technology in developing countries. An example of the latter: a blockchain-enabled coffee grading machine aimed at smallholder farmers.

Developed by a startup called Bext360, the Coinstar-like kiosk combines artificial intelligence with a way of time-stamping coffee “cherries” (the fruits containing coffee seeds or beans) as they begin their journey from remote village to New York cafe. That offers traceability to end buyers and helps the farmers win better deals for their produce, says Bext360’s CEO Daniel Jones.

Small farmers in developing countries–who produce 70%-80% of the world’s coffee supply–are often at a market disadvantage, Jones says. Middlemen decide on the quality of the crop (and have an incentive to downgrade it), set prices, and decide how, and when, farmers get paid. The kiosk, on the other hand, gives objective feedback on coffee, and pays farmers immediately.

Farmers pour in their crop. The machine automatically grades beans for color, size, and other characteristics, comparing a generated image of the cherries against a library of different types. Bext360 has spent the last 18 months training its algorithms to identify dozens of cherry details. The unit makes an offer for the produce, and the grower decides whether to accept. If the answer is “yes,” the money is wired there and then to their cell phone. Coffee buyers, meanwhile, need to empty the kiosks as they reach a limit of about 70 pounds. Jones says automation makes this a smooth process: once full, a signal can go out from the machine to a driver, saying when the machine needs attention.