Transesterification of a phosphate diester by divalent and trivalent metal ions