Abstract: Traversing risky terrains with sparse footholds poses a significant challenge for humanoid robots, requiring precise foot placements and stable locomotion. Existing approaches designed for quadrupedal robots often fail to generalize to humanoid robots due to differences in foot geometry and unstable morphology, while learning-based approaches for humanoid locomotion still struggle with complex terrains. In this paper, we introduce BeamDojo, a novel learning-based control framework that first enables agile humanoid locomotion on sparse beams. BeamDojo leverages a two-stage reinforcement learning (RL) approach that emphasizes fully trial-and-error exploration, and incorporates a newly designed foothold reward function tailored for polygonal feet and a double-head critic for sparse foothold reward learning. Extensive simulation and real-world experiments demonstrate that BeamDojo achieves efficient learning in simulation and enables agile locomotion with precise foot placement on sparse footholds in the real world, maintaining a high success rate even under significant external disturbances.