Hope all is well, iām having an issue trying to obtain the marketplace address when running truffle migrate --reset as follows:
3_marketplace_migrations.js
===========================
ReferenceError: ShowCaseNFTMarketContract is not defined
at module.exports (C:\Users\dell\Desktop\ShowcaseNFT\contracts\migrations\3_marketplace_migrations.js:4:19)
at Migration._load (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:60:1)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at Migration.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:212:1)
at Object.runMigrations (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
at Object.runFrom (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
at Object.runAll (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\wbuild\webpack:\packages\migrate\index.js:114:1)
at Object.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpld\webpack:\packages\migrate\index.js:79:1)
at runMigrations (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\wbuild\webpack:\packages\core\lib\commands\migrate.js:263:1)
at Object.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpld\webpack:\packages\core\lib\commands\migrate.js:228:1)
Truffle v5.3.5 (core: 5.3.5)
Node v14.16.1
3_marketplace_migrations.js file
const ShowcaseNFTMarketContract = artifacts.require("ShowcaseNFTMarketContract");
module.exports = function (deployer) {
deployer.deploy(ShowCaseNFTMarketContract);
};
marketplace.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol";
contract ShowcaseNFTMarketContract {
struct AuctionItem {
uint256 id;
address tokenAddress;
uint256 tokenId;
address payable seller;
uint256 askingPrice;
bool isSold;
}
AuctionItem[] public itemsForSale;
mapping (address => mapping (uint256 => bool)) activeItems;
event itemAdded(uint256 id, uint256 tokenId, address tokenAddress, uint256 askingPrice);
event itemSold(uint256 id, address buyer, uint256 askingPrice);
modifier OnlyItemOwner(address tokenAddress, uint256 tokenId){
IERC721 tokenContract = IERC721(tokenAddress);
require(tokenContract.ownerOf(tokenId) == msg.sender);
_;
}
modifier HasTransferApproval(address tokenAddress, uint256 tokenId){
IERC721 tokenContract = IERC721(tokenAddress);
require(tokenContract.getApproved(tokenId) == address(this));
_;
}
modifier ItemExists(uint256 id){
require(id < itemsForSale.length && itemsForSale[id].id == id, "Could not find item");
_;
}
modifier IsForSale(uint256 id){
require(itemsForSale[id].isSold == false, "Item is already sold!");
_;
}
function addItemToMarket(uint256 tokenId, address tokenAddress, uint256 askingPrice) OnlyItemOwner(tokenAddress,tokenId) HasTransferApproval(tokenAddress,tokenId) external returns (uint256){
require(activeItems[tokenAddress][tokenId] == false, "Item is already up for sale!");
uint256 newItemId = itemsForSale.length;
itemsForSale.push(AuctionItem(newItemId, tokenAddress, tokenId, payable(msg.sender), askingPrice, false));
activeItems[tokenAddress][tokenId] = true;
assert(itemsForSale[newItemId].id == newItemId);
emit itemAdded(newItemId, tokenId, tokenAddress, askingPrice);
return newItemId;
}
function buyItem(uint256 id) payable external ItemExists(id) IsForSale(id) HasTransferApproval(itemsForSale[id].tokenAddress,itemsForSale[id].tokenId){
require(msg.value >= itemsForSale[id].askingPrice, "Not enough funds sent");
require(msg.sender != itemsForSale[id].seller);
itemsForSale[id].isSold = true;
activeItems[itemsForSale[id].tokenAddress][itemsForSale[id].tokenId] = false;
IERC721(itemsForSale[id].tokenAddress).safeTransferFrom(itemsForSale[id].seller, msg.sender, itemsForSale[id].tokenId);
itemsForSale[id].seller.transfer(msg.value);
emit itemSold(id, msg.sender,itemsForSale[id].askingPrice);
}
}
Hope this is enough.
Much appreciated