0

Is there any way to call a ERC-721 transfer function without being the owner? This is my code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract Tink is ERC721 {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIdCounter;

    constructor() ERC721("Tink", "TNT") { 

    }

    function _baseURI() internal pure override returns (string memory) {
        return "https://gateway.pinata.cloud/ipfs/QmX8ih22uNW5cDH5CeorzpTHTbsioFurgD6w5q7RKt298H";
    }


    function mint(address to)
        public returns (uint256)
    {
        require(_tokenIdCounter.current() < 3); 
        _tokenIdCounter.increment();
        _safeMint(to, _tokenIdCounter.current());

        return _tokenIdCounter.current();
    }
}

1 Answer 1

0

Yes. Here are your options:

  1. Be approved for that specific token
  2. Be approved for all from that token's owner
  3. Edit the token contract to specifically allow this contract to make transfers
2
  • What about option 3?
    – GGK1000
    Commented Nov 16, 2021 at 2:49
  • That is something you would need to do before the contract was deployed. Or if it is an abomination, by upgrading the contract. In this case, the contract will have the transfer functions overriden to support these additional workflows. Commented Nov 16, 2021 at 15:17

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.