No, slaves did not work on the U.S. transcontinental railroad when it was built in the 1860s.
By the time work began in the 1860s, the Civil War was already raging and slavery was on its way out.
Instead, two work crews began laying track from the two ends of the railroad line, and they met in Utah.
The laborers from the east were mostly Irish and the ones from the west, mostly Chinese.