DocstringParsingError: Documentation tag @custom:oz-upgrades-unsafe-allow not valid for contracts

I’ve implemented the tutorial on UUPS proxies (link) but my code won’t compile due to the following error:

DocstringParsingError: Documentation tag @custom:oz-upgrades-unsafe-allow not valid for contracts.
  --> @openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:10:1:
   |
10 | /**
   | ^ (Relevant source part starts here and spans across multiple lines).


Error HH600: Compilation failed

My package.json dependencies:

"@nomiclabs/hardhat-ethers": "^2.0.2",
"@openzeppelin/contracts-upgradeable": "^4.1.0",
"@openzeppelin/hardhat-upgrades": "^1.7.0",
"ethers": "^5.1.4",
"hardhat": "^2.2.1"

Any help would be appreciated.

2 Likes

Hi, welcome! :wave:

Could you please share the full code?

Thankyou, long time lurker :slight_smile:

Yep, its just the code from the tutorial

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";

contract MyTokenV1 is Initializable, ERC20Upgradeable, UUPSUpgradeable, OwnableUpgradeable  {

    function initialize() initializer public {

      __ERC20_init("MyToken", "MTK");

      _mint(msg.sender, 1000 * 10 ** decimals());

    }

    function _authorizeUpgrade(address) internal override onlyOwner {}

}

Test

const MyTokenV1 = await ethers.getContractFactory('MyTokenV1');
await upgrades.deployProxy(MyTokenV1, { kind: 'uups' });

Hi @reapz, sorry you ran into this problem! I assume you’re on Windows.

Please use Solidity 0.8.3 or newer.

There is a problem with the 0.8.2 build of Solidity for Windows.

1 Like

Cool that fixed it, thanks :slight_smile:

I am on Windows. Hopefully this helps other people if anyone gets this error message, no solutions were coming up when I was searching.

2 Likes

Yes, thank you for asking! I’ve also updated the tutorial to recommend using 0.8.3.

2 Likes

Thank you. It solved the error