Efficient resource use is a very important issue in wireless sensor networks and decentralized IoT-based systems. In this context, a smooth pathfinding mechanism can achieve this goal. However, since this problem is a Non-deterministic Polynomial-time (NP-hard) problem type, metaheuristic algorithms can be used. This article proposes two new energy-efficient routing methods based on Incremental Grey Wolf Optimization (I-GWO) and Expanded Grey Wolf Optimization (Ex-GWO) algorithms to find optimal paths. Moreover, in this study, a general architecture has been proposed, making it possible for many different metaheuristic algorithms to work in an adaptive manner as well as these algorithms. In the proposed methods, a new fitness function is defined to determine the next hop based on some parameters such as residual energy, traffic, distance, buffer size and hop size. These parameters are important measurements in subsequent node selections. The main purpose of these methods is to minimize traffic, improve fault tolerance in related systems, and increase reliability and lifetime. The two metaheuristic algorithms mentioned above are used to find the best values for these parameters. The suggested methods find the best path of any length for the path between any source and destination node. In this study, no ready dataset was used, and the established network and system were run in the simulation environment. As a result, the optimal path has been discovered in terms of the minimum cost of the best paths obtained by the proposed methods. These methods can be very useful in decentralized peer-to-peer and distributed systems. The metrics for performance evaluation and comparisons are i) network lifetime, ii) the alive node ratio in the network, iii) the packet delivery ratio and lost data packets, iv) routing overhead, v) throughput, and vi) convergence behavior. According to the results, the proposed methods generally choose the most suitable and efficient ways with minimum cost. These methods are compared with Genetic Algorithm Based Routing (GAR), Artificial Bee Colony Based routing (ABCbased), Multi-Agent Protocol based on Ant Colony Optimization (MAP-ACO), and Wireless Sensor Networks based on Grey Wolf optimizer. (GWO-WSN) algorithms. The simulation results show that the proposed methods outperform the others.