Error with safeTransferFrom

Hi people, I have moved forward with the contract of a marketplace in a modularised way, that is, I define a contract for the marketplace itself and another one for the auction.
In the main contract I extend ERC721BurnableUpgradeable and in the Auction contract I extend ERC721HolderUpgradeable. To the ERC721HolderUpgradeable contract I pass in its migration the address of the main contract (which has an IERC721Upgradeable interface).

Everything went smoothly, mint, auction creation, 1-2-x placeBid...
Now when I want to make the claim from the admin account I have this error that I don't understand why I get when I execute the safeTransferFrom method...

tokenContract.safeTransferFrom(msg.sender, _auction_bidder[tokenContract][tokenId], tokenId);

reason: 'ERC721: transfer caller is not owner nor approved'...

Any suggestions?


If I understand correctly the Auction contract is calling tokenContract.safeTransferFrom(msg.sender, ...).

This will only work if the Auction contract has approval to transfer the token on behalf of whoever msg.sender is. The token holder (msg.sender) would have to either approve or setApprovalForAll to the Auction contract address when they place the token up for bidding.

Another option is that the token holder can transfer the token to the Auction contract.

1 Like

Hi Francisco, I'm Argentinian too :wink:
I share the contract with you.

I'm trying what you say, in mint, of the main contract, but I can't get it to approve me with msg.sender.... I have also tried passing the address of the aunction contract.

Hola! :argentina:

approve and setApprovalForAll have to be called by the user on their own, from their own wallet (and not through the auction contract).

If you want the ERC721 to automatically approve the auction contract, you can use the internal _approve function that will place no access control requirements.