What do animals such as clams and oysters extract from the water to build their shells?

Animals such as clams and oysters extract dissolved forms of calcium and carbonate ions from the water to build their shells. They absorb these ions through their gills and use them to form calcium carbonate, the main component of their shells.