Melt butter over medium-high heat in a large skillet. Crack eggs into the pan and cook to desired firmness. Just before eggs are cooked, place a slice of cheese over each egg; continue to cook until cheese has melted.
Transfer each egg to a toasted slice of bread. Season eggs with salt and pepper. Spread mayonnaise and ketchup on remaining slices of bread and cover eggs with bread to make 4 sandwiches. Serve warm.