0

in the WolfGame V2, their new contract WoolfReborn.sol(https://etherscan.deth.net/address/0x7f36182dee28c45de6072a34d29855bae76dbe2f) can burn NFT from old contract Woolf.sol(https://etherscan.deth.net/address/0xeb834ae72b30866af20a6ce5440fa598bfad3a42)

by use the function

function _attemptBurn(address owner, uint256 tokenId) internal 
{
    woolf.transferFrom(owner, address(0xdead), tokenId);
} 

how did they do that? in Woolf the transferFrom is

 function transferFrom(
    address from,
    address to,
    uint256 tokenId
  ) public virtual override {
    // Hardcode the Barn's approval so that users don't have to waste gas approving
    if (_msgSender() != address(barn))
      require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
    _transfer(from, to, tokenId);
  }

It require _msgSender() is approved or owner, but the new contract is not the owner of the NFT, and there is no code to let the new contract get approved

2 Answers 2

0

They are actually checking if the msg.sender is the owner before minting it.

   /**
   * creates identical tokens in the new contract
   * and burns any original tokens that are not in the barn
   * @param tokenIds the ids of the tokens to migrate
   */
  function migrate(uint256[] calldata tokenIds) external whenNotPaused {
    for (uint i = 0; i < tokenIds.length; i++) {
      (address owner, bool inBarn) = _ownerOf(tokenIds[i]);
      require(owner == _msgSender(), "STOP! THIEF!");
      if (!inBarn) _attemptBurn(_msgSender(), tokenIds[i]);
      _mint(_msgSender(), tokenIds[i]); // built-in duplicate protection
    }
  }
1
  • yes , the new contract checked, but how the new contract let the old contract burn wolf?
    – JESSE Bin
    Commented May 4, 2022 at 12:00
0

If your new contracts get the approve the NFT permission then will be resolve the your issue.

Try this:

function migrate(uint256[] calldata tokenIds) external whenNotPaused {
    for (uint i = 0; i < tokenIds.length; i++) {
      (address owner, bool inBarn) = _ownerOf(tokenIds[i]);
      require(owner == _msgSender(), "STOP! THIEF!");

      if (!inBarn) {
         woolf._approve(address(this),tokenId);   // approve the tokenIDs Wise
        _attemptBurn(_msgSender(), tokenIds[i]);
      }

      _mint(_msgSender(), tokenIds[i]); // built-in duplicate protection
    }
  }
2
  • this is a online contract, it can burn directly, there no approve method in new contract, so I wonder how they did it
    – JESSE Bin
    Commented May 4, 2022 at 13:08
  • This approve method will be called from your old contract. Commented May 4, 2022 at 13:10

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.