This paper presents an algorithm for construction of a digital starshaped polygon with given center, which can be inscribed in the square grid of given size and which has the maximal possible number of edges. It is proved that the proposed algorithm is asymptotically optimal.