In this paper we describe an algorithm for solving the one-dimensional Stefan problem by involving metal shrinkage. In this algorithm we use the finite element method supplemented by the procedures allowing to define the position of moving interface and the change material size associated with shrinkage. We present also some examples illustrating the precision of the presented method.