This paper introduces a novel approach to constructing all-optical logic gates based on metalens. The designed structure enables the realization of five commonly used logic gates (AND, OR, NOT, XOR, XNOR). Each logic gate is composed of two to three metalenses. The advantages of this approach are as follows: 1. Metalens offer flexible phase control capabilities, overcoming the strict phase requirements in traditional optical logic gate design. 2. The miniaturization of the metalens makes integration possible and provides a potential method for high-speed parallel optical computing. 3. By controlling different types and quantities of metalens, various types of logic gates can be formed, enhancing programmability during use. The contrast values for the designed logic gates are as follows: 27.95 dB (OR), 18.18 dB (AND), 10.83 dB (NOT), 10.29 dB (XNOR), and 13.56 dB (XOR). With similar structures, the bit rates for the five logic gates at a 50% duty cycle range from 1.04 to 1.05 Tb/s. Overall, these results demonstrate a successful balance between contrast and transmission speed when utilizing metalens to realize all-optical logic gates. From the results, the logic gate proposed in this paper has high contrast and transmission speed, which proves the rationality of using metalens to realize all-optical logic gate.