This is as I heard from the Blessed One. At one time the Blessed One was staying in the province of Sāvatthī, in Jeta’s park, at Anathapindika’s monastery.
One day, on a road between the city of Sāvatthī and Jeta’s park, a group of boys were hitting a snake with a stick. Then early in the morning the Blessed One, having worn his robe, taken his bowl and his double robe, entered the village to collect almsfood. He saw the group of boys on the road hitting the snake with a stick.
Then, on realizing the true way to happiness in the world, the Blessed One spoke the following inspired verses:
Desiring his own happiness,
whoever harms another being
who also desires happiness,
will not obtain happiness after death.Desiring his own happiness,
if somebody does not harm other beings
who also desire happiness,
will obtain happiness after death.
Read this translation of Udāna 2.3 Danda Sutta: Children with Sticks by Ven. Kiribathgoda Gnanananda Thero on ReadingFaithfully.org. Or read a different translation on SuttaCentral.net, DhammaTalks.org, or Ancient-Buddhist-Texts.net.