First, the farmer travels across the river with the chicken, leaving the fox with the bag of corn on the other side. When he gets across the river, he leaves the chicken. When he travels back across the river, he retrieves the fox. When he gets back home, he takes the chicken back across the river because he can’t leave the fox alone with the chicken.
Then he trades the chicken for the bag of corn, leaving the chicken all alone on the other side. He drops off the bag of corn at home. Then he makes a final trek back across the river to retrieve the chicken. Once he’s done, he’s successfully transported all three items across the river while keeping everything intact.