@Amxx Thank you so much, that makes a lot of sense,
The following code works:
const transferFromOwnerToMarketplace = await openseaContract.safeTransferFrom(
tokenOwnerAddress,
aDifferentUserAddress,
tokenId,
1,
"0x"
);
the token is transferred directly from the owner to the other user and does not require setApprovalForAll, but requires the user to sign the transaction.
Following your advice, if I want mySmartContract to transfer the token on behalf of the user, I would do:
if (!(await contract.isApprovedForAll(tokenOwnerAddress, mySmartContractAddress))) {
const setApprovalTransaction = await openseaContract.setApprovalForAll(
mySmartContractAddress,
true
);
await setApprovalTransaction.wait();
}
Followed by:
const transferFromOwnerToMarketplace = await openseaContract.safeTransferFrom(
mySmartContractAddress,
aDifferentUserAddress,
tokenId,
1,
"0x"
);
But this is where I get the error:
reason="execution reverted: AssetContractShared#_requireMintable: ONLY_CREATOR_ALLOWED"
which takes me back to thinking that even if the user has approved mySmartContractAddress to transfer their tokens, the safeTransferFrom in the Opensea Contract does not allow anyone apart from the owner to call safeTransferFrom.
Would that observation be correct?
And if it is correct, would you suggest having the tokenId owner transfer their token to mySmartContract first, for mySmartContract to then transfer to aDifferentUserAddress?
What I am trying to do is have a user transfer their already existing tokens minted on Opensea to another user when a certain condition is met in the future. I cannot have the owner sign safeTransferFrom (because of the 'in the future' component) so I wanted to delegate this to mySmartContract.