0
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/[email protected]/token/ERC721/ERC721.sol";

contract NFTERC721 is ERC721 {
    uint256 private _nextTokenId;

    constructor()
        ERC721("NFTERC721", "NFT721")
    {}

    function safeMint(address to) public {
        uint256 tokenId = _nextTokenId++;
        _safeMint(to, tokenId);
    }
}

This is the token contract code . I am trying to deploy this contract on Avalanche Fuji testnet , but I get an error . ( Refer the image attached ) enter image description here

why is the contract not getting deployed ?

1 Answer 1

3

Solidity 0.8.20 introduced the PUSH0(0x5f) opcode which is only supported on the ETH mainnet and not on any other chains. That's why other chains can't find the PUSH0(0x5f) opcode and throw this error.

Consider either using 0.8.19 for other chains, or use a different EVM version, other than shanghai.

This should solve your problem.

If you want to learn more about PUSH0 opcode you can check this small article which explains it pretty well. https://www.zaryabs.com/push0-opcode/

3
  • even after using 0.8.19 for the Solidity version , the problem does not get solved . It is because I am importing Openzeppelin contracts v5 ( these contracts are using solidity v0.8.20 . Is it ok to use Openzeppelin contacts v4.7.3 ( these contracts use solidity ^0.8.0 ) ? Nov 3, 2023 at 4:56
  • Yup, that's totally okay to use. It's all up to your needs. All versions of OZ contracts are fine. But also try to use a different compiler version, just to see if that's more easy for you. Either way is fine, whatever suits you. Nov 3, 2023 at 6:57
  • okay bro , thanks ! Nov 3, 2023 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.