# Nonces .sol safe to use?

**URL:** <https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772>\
**Category:** Contracts\
**Created:** [June 20, 2023, 3:21pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772 "2023-06-20T15:21:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodrigo\_Pintos](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/rodrigo_pintos/32/23255_2.png) [@Rodrigo\_Pintos](https://forum.openzeppelin.com/u/Rodrigo_Pintos)\
**Post date:** [June 20, 2023, 3:21pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/1 "2023-06-20T15:21:01Z")

</div>

Hi there,

I have installed "@openzeppelin/contracts": "^4.9.2" and I noticed that Nonces.sol is not bundled on it.

How safe is to use the once in the repo?

> <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Nonces.sol>

Thx.

---

<div class="post-metadata">

**Author:** ![barakman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/barakman/32/855_2.png) [@barakman](https://forum.openzeppelin.com/u/barakman)\
**Post date:** [June 20, 2023, 8:06pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/2 "2023-06-20T20:06:30Z")

</div>

Looks safe.

[This function](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Nonces.sol#L15-L20):

```auto
    /**
     * @dev Returns an address nonce.
     */
    function nonces(address owner) public view virtual returns (uint256) {
        return _nonces[owner];
    }

```

Should probably be renamed, since it returns a single nonce rather than several nonces.  
That's just semantics of course, but perhaps it indicates that this contract is work-in-progress.

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Pintos](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/rodrigo_pintos/32/23255_2.png) [@Rodrigo\_Pintos](https://forum.openzeppelin.com/u/Rodrigo_Pintos)\
**Post date:** [June 20, 2023, 9:40pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/3 "2023-06-20T21:40:17Z")

</div>

Thx for the replay!

How do u believe this method would be called? nonce? getNonce?

Just to deploy it with a different name. Thx in advance

---

<div class="post-metadata">

**Author:** ![barakman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/barakman/32/855_2.png) [@barakman](https://forum.openzeppelin.com/u/barakman)\
**Post date:** [June 21, 2023, 7:01am UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/4 "2023-06-21T07:01:41Z")

</div>

Well, `nonce` would be the most suitable as far a OZ naming convention goes (in opposed to `getNonce`, for example).

But it is already in use as a local variable in other functions, so that's gonna give a compilation error (or at least warning).

Same goes for `currentNonce`.

Perhaps `usedNonce` is suitable enough.

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Pintos](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/rodrigo_pintos/32/23255_2.png) [@Rodrigo\_Pintos](https://forum.openzeppelin.com/u/Rodrigo_Pintos)\
**Post date:** [June 21, 2023, 3:58pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/5 "2023-06-21T15:58:07Z")

</div>

Mmm not sure if usedNonce is a good name for it because, nonces method returns the currentNonce (the once to be used) instead of the last nonce used.

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Pintos](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/rodrigo_pintos/32/23255_2.png) [@Rodrigo\_Pintos](https://forum.openzeppelin.com/u/Rodrigo_Pintos)\
**Post date:** [June 21, 2023, 5:26pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/6 "2023-06-21T17:26:18Z")

</div>

Well, finally I decided not to change it because it seems is already being used in the [IERC20Permit](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Permit.sol) so...

not sure if its something its gonna change in the future.

---

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [June 21, 2023, 9:16pm UTC](https://forum.openzeppelin.com/t/nonces-sol-safe-to-use/36772/7 "2023-06-21T21:16:00Z")

</div>

Folks please read the [README](https://github.com/OpenZeppelin/openzeppelin-contracts#readme) there is a big disclaimer at the top:

> **Warning** Version 5.0 is under active development. The code in this branch is not recommended for use

As a general recommendation you should avoid using the `master` or `main` branch of a library... There is a reason we do releases.
