title: ERC721 Sell/Buy NFT Solidity
body: <p>I have a very strange behavior when I try to sell NFT, when the token gets to the buyer, it turns out with nulled parameters. I can't understand why this is happening. Please explain what I'm doing wrong.</p>
  <p>My function in contract:</p>
  <pre><code>    function buyNft(uint tokenId) public payable {
          uint price = _idToNftItem[tokenId].price;
          address owner = ERC721.ownerOf(tokenId);
          
          require(msg.sender != owner, 'You already own this NFT');
          require(msg.value == price, &quot;Please submit the asking price&quot;);
  
          _idToNftItem[tokenId].isListed = false;
          _listedItems.decrement();
  
          _transfer(owner, msg.sender, tokenId);
          payable(owner).transfer(msg.value);
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/YprSs.png" rel="nofollow noreferrer">My test code</a>
  <a href="https://i.stack.imgur.com/pozHW.png" rel="nofollow noreferrer">Test result</a></p>