A tattoo gun is a device that uses high-voltage electricity to create a spark between two metal pieces, called electrodes. When these sparks occur, they cause the ink to melt and transfer onto the skin.
https://www.tattoorevolutions.com/tattoo-gun/
A tattoo machine works similarly, except that it creates the sparks using a needle instead of electrodes.