# How to read the current minted token id using ERC721 preset

**URL:** <https://forum.openzeppelin.com/t/how-to-read-the-current-minted-token-id-using-erc721-preset/7508>\
**Category:** Contracts\
**Tags:** openzeppelin-contracts\
**Created:** [April 28, 2021, 4:31pm UTC](https://forum.openzeppelin.com/t/how-to-read-the-current-minted-token-id-using-erc721-preset/7508 "2021-04-28T16:31:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![intoverq](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@intoverq](https://forum.openzeppelin.com/u/intoverq)\
**Post date:** [April 28, 2021, 4:31pm UTC](https://forum.openzeppelin.com/t/how-to-read-the-current-minted-token-id-using-erc721-preset/7508/1 "2021-04-28T16:31:32Z")

</div>

Need to get the “current” tokenId to use it in other functions.

How would a contract implementing ERC721PresetMinterPauserAutoIdUpgradeable acces the current counter, before the minting process (ar after it)

**💻 Environment**  
“@openzeppelin/contracts-upgradeable”: “^4.0.0”,  
“truffle”: “^5.3.1”

**📝Details**

Example solution that does not work because of private \_tokenIdTracker

```
TestContract is ERC721PresetMinterPauserAutoIdUpgradeable {
...
//would not work private varibale _tokenIdTracker
 function getCurrentCounter() public view returns (uint256){
    return _tokenIdTracker.current();
 }
}
```

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 29, 2021, 4:07am UTC](https://forum.openzeppelin.com/t/how-to-read-the-current-minted-token-id-using-erc721-preset/7508/2 "2021-04-29T04:07:35Z")

</div>

Hi @intoverq,

State variables are private and there isn’t a getter that you can use.

Instead you can use the ideas from the Preset and create your own contract extending from ERC721.

See the documentation:  
[https://docs.openzeppelin.com/contracts/4.x/extending-contracts](https://docs.openzeppelin.com/contracts/4.x/extending-contracts)

Also the Contracts Wizard:

> **[OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/)**
>
> An interactive contract generator based on OpenZeppelin Contracts.

---

<div class="post-metadata">

**Author:** ![intoverq](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@intoverq](https://forum.openzeppelin.com/u/intoverq)\
**Post date:** [April 29, 2021, 9:15am UTC](https://forum.openzeppelin.com/t/how-to-read-the-current-minted-token-id-using-erc721-preset/7508/3 "2021-04-29T09:15:59Z")

</div>

That’s would be the solution, thanks for confirming it
