In recent years, while blockchain has brought security to anti-counterfeiting traceability systems, its Practical Byzantine Fault Tolerance (PBFT) has always had poor scalability issues, especially as the number of nodes in the network increases, the difficulty of anti-counterfeiting traceability will increase exponentially. To address this issue, this article first generates random numbers through the verifiable random function RandHound, and nodes are partitioned based on the random numbers. Conduct anti-counterfeiting measures. Secondly, a traceability strategy based on verifiable random functions was designed using the (Artificial Fish Swarm Algorithm, AFSA), and the main node was ultimately obtained through iteration using the AFSA algorithm. Finally, the final consensus committee is selected through a verifiable random function, which is responsible for authenticating the client’s request. Compared with traditional methods, the improved AFSA algorithm has the characteristics of more acceptable nodes and low latency in anti-counterfeiting traceability problems.