Ankr.

帖子

分享您的知识。

GMAIL.
Jun 12, 2025
专家问答

Counter.sol not found in Openzeppelin Contracts

What is the replacement for Counter.sol in Openzeppelin contracts? I get this error when I try to run my contract:

lib/openzeppelin-contracts/contracts/utils/Counters.sol": No such file or directory (os error 2)

  • Polygon Miden
  • MATIC
  • dApp
1
3
分享
评论
.

答案

3
Protocol Dev.
Jun 12 2025, 12:47

Counter.sol not found in Openzeppelin Contracts What is the replacement for Counter.sol in Openzeppelin contracts? I get this error when I try to run my contract:

lib/openzeppelin-contracts/contracts/utils/Counters.sol": No such file or directory (os error 2)

0
官方答案
评论
.
Protocol Dev.
Jun 17 2025, 12:25

Counter.sol not found in Openzeppelin Contracts What is the replacement for Counter.sol in Openzeppelin contracts? I get this error when I try to run my contract:

Protocol Dev.
Aug 5 2025, 06:03

lib/openzeppelin-contracts/contracts/utils/Counters.sol": No such file or directory (os error 2)

GMAIL.
Jun 12 2025, 11:53

It has been removed in openzeppelin v5 and most likely not coming back. You can either downgrade OZ version to 4.x, which is not recommended since a lot of patches have been merged since then fixing various vulnurabilities, or you can replace counter with something else, in most cases a single variable will do the trick. For more details I'll advise to check out the PR which removed Counters.sol from OZ codebase - it contains the reasoning behind this move and different strategies how one can move on without it

1
评论
.
Email 50.
Aug 15 2025, 11:29

Generative AI: Creation of content through advanced AI models is transforming content generation, automation, and design.

Quantum Computing: Expected to revolutionize cryptography, drug discovery, and problem-solving for complex systems.

Augmented Reality (AR) & Virtual Reality (VR): New immersive experiences in gaming, training, and consumer applications.

0
评论
.
Email 50.
Aug 15 2025, 11:30

Quantum Computing: Expected to revolutionize cryptography, drug discovery, and problem-solving for complex systems.

你知道答案吗?

请登录并分享。