2

I'm wondering how opensea transferring tokens to the buyer without having the ownership of that token.And also they are not using escrow account at all.In remix, If i tried to transfer the token without the ownershipp , It's not working and giving error "ERC721: transfer caller is not owner nor approved". How can i do this action like opensea..

2

2 Answers 2

2

OpenSea has a contract ERC721Tradable.sol that whitelist the OpenSea operator

    /**
     * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings.
     */
    function isApprovedForAll(address owner, address operator)
        override
        public
        view
        returns (bool)
    {
        // Whitelist OpenSea proxy contract for easy trading.
        ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
        if (address(proxyRegistry.proxies(owner)) == operator) {
            return true;
        }

        return super.isApprovedForAll(owner, operator);
    }
6
  • Okay I have Aproved the certain accounts while transferring the token. Which address i have to use as a from address,while transferring tokens. If i use the aproved address, It showing error like "Transferring of token that not owned". Also if i want to use owner address i have to be the owner while transferring tokens. Jul 1, 2021 at 7:05
  • Sorry, but I don't understand. Are you developing your own contract? or you are using opensea contracts?
    – Ismael
    Jul 2, 2021 at 2:00
  • Yeah I'm developing contracts using openzeppelin library for ERC721 Jul 2, 2021 at 6:20
  • @MAHENDRANKANAGARAJ without the code is hard to say, usually from is the token's owner and msg.sender is the operator. But those are names that are easy to change in the code.
    – Ismael
    Jul 3, 2021 at 18:52
  • I saw the opensea contracts. Can you please explain the function in line 91 github.com/ProjectOpenSea/opensea-creatures/blob/master/… Jul 5, 2021 at 8:30
1

You can transfer the token without the ownership. If you give an address approval, the address can transfer the token.

function approve(address _approved, uint256 _tokenId)

This function is used to give an address approval. In the transfer function of ERC-721. The from address must be either the token owner or have an approval.

Here is the transfer function

function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }
1
  • I have used the contract address as approved address from the owner. Then i tried to transfer the tokens, But it showing error like "Your balance should be higher than you send" Jul 1, 2021 at 7:09

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.