The devices can "melt away" once their job is done, according to research published in the journal Science.
The technology has already been used to heat a wound to keep it free from infection by bacteria.
The speed of melting is controlled by silk. The material is collected from silkworms, dissolved and then allowed to reform. Altering the way the dissolved silk crystallises changes its final properties — and how long the device will last.