I am using web3py to make a transaction. But I am getting validation error:
{'message': 'VM Exception while processing transaction: revert Need
operator approval for 3rd party transfers.', 'code': -32000, 'data':
{'stack': 'RuntimeError: VM Exception while processing transaction:
revert Need operator approval for 3rd party transfers.\n at
Function.RuntimeError.fromResults
(/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/utils/runtimeerror.js:89:13)\n
at module.exports
(/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/utils/gas/guestimation.js:142:32)',
'name': 'RuntimeError'}}
Can someone please help me understand this error? Why is it happening?
I am using function safeTransferFrom (from ERC1155)
Thank you.
Best Answer
If we refer to the doc (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md), we can read in the definition of the
safeTransferFrom
function :The user passed to the
_from
parameter ofsafeTransferFrom
has therefore to first approve the caller usingsetApprovalForAll(address _operator, bool _approved)
with :_operator
the address of thesafeTransferFrom
caller which can be either an EOA or a smart contract_approved
set totrue
.To resume:
setApprovalForAll
transaction with_approved
set to false.