Context. A previous study of solar twin stars has revealed the existence of correlations between some abundance ratios and stellar age providing new knowledge about nucleosynthesis and Galactic chemical evolution. Aims. High-precision abundances of elements are determined for stars with asteroseismic ages in order to test the solar twin relations. Methods. HARPS-N spectra with signal-to-noise ratios S /N > ∼ 250 and MARCS model atmospheres were used to derive abundances of C, O, Na, Mg, Al, Si, Ca, Ti, Cr, Fe, Ni, Zn, and Y in ten stars from the Kepler LEGACY sample (including the binary pair 16 Cyg A and B) selected to have metallicities in the range −0.15 < [Fe/H] < +0.15 and ages between 1 and 7 Gyr. Stellar gravities were obtained from seismic data and effective temperatures were determined by comparing non-LTE iron abundances derived from Fe i and Fe ii lines. Available non-LTE corrections were also applied when deriving abundances of the other elements.