remix-project icon indicating copy to clipboard operation
remix-project copied to clipboard

Source location not available while debugging

Open yzhou61 opened this issue 2 years ago • 1 comments

When debugging a transaction, if I jump to a location outside of my contract (a call to some other contract, for example), Remix shows the following error message:

Source location not available, neither in Sourcify nor in Etherscan. Please make sure the Etherscan api key is provided in the settings.

However, I do have Etherscan API key setup already. I also have that target contract imported in Sourcify. What else am I missing?

yzhou61 avatar Jun 09 '22 21:06 yzhou61

could you post the transaction hash, the network, and the vm trace index where that call happens?

yann300 avatar Jun 13 '22 13:06 yann300

@Aniket-Engg I am also facing the same issue.

@yann300 transaction hash: 0xeb7de6c740a8f7ee43758a31f71d6726aa55eaffe8e8e4a47f579340123524ed network: remix VM London (remix web IDEs own network) vm trace step: 181

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract NFT is ERC721URIStorage {

    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;
    address contractAddress;
    
    constructor(address marketplaceAddress) ERC721("Metaverse Tokens","METT") {
    contractAddress=marketplaceAddress;
    
    }

   function createToken(string memory tokenURI) public returns(uint){  
       _tokenIds.increment();
       uint256 newItemId=_tokenIds.current();
       _mint(msg.sender,newItemId); 
       _setTokenURI(newItemId,tokenURI);

       setApprovalForAll(contractAddress,true);
       return newItemId;     
   } 
}

contract NFTMarket is ReentrancyGuard{

    using Counters for Counters.Counter;
    Counters.Counter private _itemIds;
    Counters.Counter private _itemsSold;

    address payable owner;
    uint256 listingPrice=0.001 ether;
    constructor() {
        owner=payable(msg.sender);
    }

    struct Marketitem {
        uint itemId;
        address nftContract;
        uint256 tokenId;

        //external account who wants to sell nft on this platform
        address payable seller;

        //owner of nft marketplace portal who gets listing fee
        address payable owner;
        uint256 price;
        bool sold;
    }
    
    mapping(uint256 => Marketitem) private idToMarketItem;
    
event MarketItemCreated(
        uint indexed itemId,
        address indexed nftContract,
        uint256 indexed tokenId,
        address seller,
        address owner,
        uint256 price,
        bool sold
    );

    function getListingPrice() public view returns (uint256) {
        return listingPrice;

    }

    function createMarketItem(
        address nftContract,
        uint256 tokenId,
        uint256 price
    )
    
    public payable nonReentrant{
       require(price > 0, "Price should at least be 1 wei");
       require(msg.value == listingPrice,"Price must be equal to listing price");

       _itemIds.increment();
       uint256 itemId= _itemIds.current();

       idToMarketItem[itemId] = Marketitem(
           itemId,
           nftContract,
           tokenId,
           payable(msg.sender),
           payable(address(0)),
           price,
           false
       ); 




    
        IERC721(nftContract).transferFrom(msg.sender,address(this),tokenId);  
        emit MarketItemCreated(
            itemId,
            nftContract,
            tokenId,
            msg.sender,
            address(0),
            price,
            false
        );
        
        }
    
    function createMarketSale(
        address nftContract,
        uint256 itemId

        //we dont need to pass the price since the price has been updated in 
        //the state of the smart contract on blockchain when we created the 
        //nft in the previous function i.e function createMarketItem
        
    )   public payable nonReentrant {
        uint price = idToMarketItem[itemId].price;
        uint tokenId=idToMarketItem[itemId].tokenId;
        require(msg.value==price, "Please submit the asking price in order to complete the purchase");

        idToMarketItem[itemId].seller.transfer(msg.value);

        IERC721(nftContract).transferFrom(address(this),msg.sender,tokenId);

        idToMarketItem[itemId].owner = payable(msg.sender);
        idToMarketItem[itemId].sold=true;
        _itemsSold.increment();
        payable(owner).transfer(listingPrice);

    }

    function fetchMarketItems() public view returns (Marketitem[] memory){
        uint itemCount = _itemIds.current();
        uint unsoldItemCount= _itemIds.current() - _itemsSold.current();
        uint currentIndex=0;

        Marketitem[] memory items = new Marketitem[](unsoldItemCount);
        for(uint i=0; i< itemCount;i++){
            if(idToMarketItem[i+1].owner==address(0)){
                uint currentId=idToMarketItem[i+1].itemId;
                Marketitem storage currentItem=idToMarketItem[currentId];
                items[currentIndex]=currentItem;
                currentIndex+=1;
            }

        }
            return items;
    }

    //fetch the nfts that you own
    function fetchMyNFTs() public view returns (Marketitem[] memory){
        uint totalItemCount=_itemIds.current();
        uint itemCount=0;
        uint currentIndex=0;

        for (uint i=0;i<totalItemCount;i++)
        {
            if(idToMarketItem[i+1].owner==msg.sender){
                itemCount+=1;
                
                }
        }
            Marketitem[] memory items=new Marketitem[](itemCount);
            for(uint i=0;i<totalItemCount;i++)
            {
                if(idToMarketItem[i+1].owner==msg.sender){
                    uint currentId=i+1;
                    Marketitem storage currentItem = idToMarketItem[currentId];
                    items[currentIndex]=currentItem;
                    currentIndex+=1;


                }
            }
            return items;
    }
    

    //fetch the nfts that you have created
    function fetchItemsCreated() public view returns (Marketitem[] memory){

        uint totalItemCount = _itemIds.current();
        uint itemCount=0;
        uint currentIndex=0;

        for (uint i=0 ; i<totalItemCount ; i++){
            if(idToMarketItem[i+1].seller==msg.sender){
                itemCount+=1;

            }
        }
        Marketitem[] memory items = new Marketitem[](itemCount);
        for(uint i=0;i< totalItemCount; i++){
            if(idToMarketItem[i+1].seller==msg.sender){
                uint currentId=i+1;
                Marketitem storage currentItem= idToMarketItem[currentId];
                items[currentIndex]=currentItem;
                currentIndex+=1;


            }
        }
        return items;
    }


}

m-waqas88 avatar Jan 31 '23 20:01 m-waqas88

as long as the contract that is being called has been compiled in remix the source location should now be displayed. A fix has been pushed recently

yann300 avatar Mar 07 '23 11:03 yann300

I am still facing this issue with 0.32.0. My API key is added correctly, yet when debugging and the call goes to an outside contract,

Source location not available, neither in Sourcify nor in Etherscan. Please make sure the Etherscan api key is provided in the settings.

TX hash: 0x98326b4eb3a82f93748c7e78ad207b41f365c91a6d4b979f0f8c686a13ca9edf on Goerli

gdetari avatar Mar 08 '23 12:03 gdetari

@gdetari How are you able to use 0.32.0? It's in development phase v0.32.0. The latest release is 0.31.2.

m-waqas88 avatar Mar 08 '23 19:03 m-waqas88

You are right, I am using 0.31.2.

On Wed, Mar 8, 2023 at 20:38, blockeater @.***> wrote:

@.***(https://github.com/gdetari) How are you able to use 0.32.0? It's in development phase v0.32.0. The latest release is 0.31.2.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

gdetari avatar Mar 08 '23 20:03 gdetari

Remix 0.33.2, issue still there.

old-mikser avatar Jun 14 '23 01:06 old-mikser