Confined molecules inside carbon nanotubes polarize under gate voltage, creating transistors with three stable logic states from a single material system.