First of all, the greenish-black color of hard-cooked egg yolks is harmless. Even if the colored substance were a toxic compound (it’s not), it is present in only trace amounts.
As an egg ages, some of the sulfur-containing protein in the egg white slowly decomposes, forming a small amount of evil-smelling hydrogen sulfide gas, H2S. Heat greatly accelerates this decomposition; at the temperature of boiling water, hydrogen sulfide will be produced in an egg almost two hundred times as fast as at room temperature.
The gas diffuses throughout the egg, and when it reaches the yolk, which contains a small amount of iron, it reacts with the iron to form iron sulfides, FeS and Fe 2S3 , known to chemists as ferrous sulfide and ferric sulfide, respectively. Ferrous sulfide happens to be black-brown, while ferric sulfide is yellow-green. Et voila! A dirty-looking egg yolk.
The exact color will depend on how much air is available inside the egg, because in the presence of air the blackish ferrous sulfide changes (it is oxidized) to the greenish ferric oxide. Because older eggs contain more air, their yolks tend to turn greener.
The longer an egg is heated and the more hydrogen sulfide gas is produced, the more it migrates to the surface of the yolk, and the greener and darker the yolk becomes. If hard-“boiled” eggs are made without actually being boiled, but simply by being left in a covered pan of water below the boiling point, the slightly lower temperature of the water will make a big difference in slowing the production and diffusion of hydrogen sulfide. As soon as the eggs are done, you should stop these ugly chemical reactions dead in their tracks by cooling the eggs in cold running water.
If your little boy wants an egg that’s green enough to pass muster with Sam, try getting him a cassowary egg. A cassowary is a large, flightless Australian bird that lays eggs averaging about 3 1/2 by 5 1/2 inches and weighing about 1 1/4, pounds. The shells are quite green, although I confess I can’t vouch for the contents.