i do auction of nft contract. I have a complex structure:

  • Contraact Users has array of User contracts, instance of NFT contract and instance of Auctions contract

  • NFt contract has createNFT and transferNFT methods.

  • Auctions contract has array of Auction contracts and methods to create new auction (auctions.push(new Auction(some, params)))

  • Auction contract receives in constructor some params and tokenId of nft. And there are methods: placeBid and finalizeAuction(transfer eth to owner and transfer nft to bidder) in Auction contract

  • And finally User contract has methods: collectNFT - by nftInstance of Users call createNFT and save tokenId. Next createAuction method by auctionInstance in Users call createAuction. Also, user can placeBid and finalizeAuction.

So, we have 2 users. The first creates new NFT, provide tokenId in createAuction. The second places a bid. Then the first finalize auction. BUT I GET ERROR - Revert ERC721: transfer caller is not owner nor approved. I know what there is setApproveForAll method, but where to call it??

I don't even know why the owner is not approved!

I tried in NFT contract call setApproveForAll(userAddress), next in User contract setApproveForAll(address(auctionsInstance)), in Auctions do that for Auction contract. But any way it is ERROR.

How is setApproveForAll works?? How to fix that? Please help me;)

enter image description here

1 Answer 1


The code for setApprovalForAll is :

function setApprovalForAll(address operator, bool approved) public virtual override {
    _setApprovalForAll(_msgSender(), operator, approved);

See here

So to approve all the tokens the user who wants to approve their tokens must call the function with the parameters: user address they want to approve, and the boolean true. To revoke the permissions you must call the same function with the boolean false.

Note: the approved user is not the owner, they are simply an approvee, you can use isApprovedForAll to check if you are approved.

  • I try this, but something is wrong;) in NFT i mint nft for user address, then in user contract i call nftInstance.setApprovForAll(addr, true) - addr of userAddres, for address(this), address(auctionsInstance). What am i doing wrong?
    – Влад
    Feb 10, 2022 at 17:33
  • i can't understand this system. I have userAddres (msg.sender in first called contract), throuth user contract in nft contract i mint nft to userAddress. And then approve for user contract, auctions, auction - everything! But if i call isApprovedForAll in remix for owner as userAddress, i get everywhere false! And then i think to try owner as address of user contract - everywhere true! Why??? Owner is userAddress (not user contract). i just can't understand this shit.
    – Влад
    Feb 11, 2022 at 17:41
  • Are you doing approve or approveForAll?
    – nemo
    Feb 11, 2022 at 23:35
  • setApproveForAll
    – Влад
    Feb 12, 2022 at 12:05
  • I can add code, but it's 500 lines
    – Влад
    Feb 12, 2022 at 12:05

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.