Contract: https://etherscan.io/address/0xec16fed4f619aacd70c7db48327d362f675bfc29
Contract.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract DogNFT is ERC721, Ownable {
using Strings for uint256;
mapping (uint256 => string) private _tokenURIs;
mapping (uint256 => uint256) public tokenIdToPrice;
string private _baseURIextended;
constructor() ERC721("DogNFT", "DNFT") {}
function setBaseURI(string memory baseURI_) external onlyOwner() {
_baseURIextended = baseURI_;
}
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseURIextended;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = _baseURI();
if (bytes(base).length == 0) {
return _tokenURI;
}
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
return string(abi.encodePacked(base, tokenId.toString()));
}
function allowBuy(uint256 _tokenId, uint256 _price) external {
require(msg.sender == ownerOf(_tokenId), 'Not owner of this token');
require(_price > 0, 'Price zero');
tokenIdToPrice[_tokenId] = _price;
}
function disallowBuy(uint256 _tokenId) external {
require(msg.sender == ownerOf(_tokenId), 'Not owner of this token');
tokenIdToPrice[_tokenId] = 0;
}
function mint(
address _to,
uint256 _tokenId,
string memory tokenURI_
) external onlyOwner() {
_mint(_to, _tokenId);
_setTokenURI(_tokenId, tokenURI_);
tokenIdToPrice[_tokenId] = 0;
}
function buy(uint256 _tokenId) external payable {
uint256 price = tokenIdToPrice[_tokenId];
require(price > 0, 'This token is not for sale');
require(msg.value == price, 'Incorrect value');
address seller = ownerOf(_tokenId);
safeTransferFrom(seller, msg.sender, _tokenId);
tokenIdToPrice[_tokenId] = 0;
payable(seller).transfer(msg.value);
}
}
I tried using flatten and it removes duplicate licenses. I also changed the pragmas and kept only one in version 0.8.0. But he keeps making an error! (ps deploy by remix)
EDIT
Trying hardhat. Output:
Error in plugin @nomiclabs/hardhat-etherscan: The address 0xec16fed4f619aacd70c7db48327d362f675bfc29 has no bytecode. Is the contract deployed to this network? The selected network is mainnet.
EDIT 2
hardhat.config.js
/**
* @type import('hardhat/config').HardhatUserConfig
*/
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
require('@nomiclabs/hardhat-ethers');
require("@nomiclabs/hardhat-etherscan");
module.exports = {
solidity: {
version: "0.8.7",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
networks: {
mainnet: {
url: `https://mainnet.infura.io/v3/xxx`,
accounts: {mnemonic: mnemonic}
}
},
etherscan: { apiKey: "xxx" }
};
output:
Error in plugin @nomiclabs/hardhat-etherscan: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts.
Possible causes are:
- Contract code changed after the deployment was executed. This includes code for seemingly unrelated contracts.
- A solidity file was added, moved, deleted or renamed after the deployment was executed. This includes files for seemingly unrelated contracts.
- Solidity compiler settings were modified after the deployment was executed (like the optimizer, target EVM, etc.).
- The given address is wrong.
- The selected network (mainnet) is wrong.
Invalid constructor arguments provided. Please verify that they are in ABI-encoded format