bfrascino80
18 days ago  Karma: 5
Can a ERC721 token be transferred without payment?

Hello all,

I'm learning solidity and I am testing some ERC721 functions. I wanted to test function setApprovalForAll() so what I did:

1 - Created 2 tokens (_mint())
2 - Did setApprovalForAll() authorizing an operator.
3 - Did safeTransferFrom(operator, a3rdUser, tokenId)
4 - Checked with ownerOf() if 'a3rdUser' now is the owner of the tokens.

I'm testing with ganache. The transaction gets reverted. It prints:

Events emitted during test:
```
---------------------------

Transfer(from: , to: , tokenId: )
Transfer(from: , to: , tokenId: )
ApprovalForAll(owner: , operator: , approved: true)

---------------------------
...

Error: VM Exception while processing transaction: revert
...
```

I noticed that the exception occurs when safeTransferFrom() is called because no code after that is reached in the test.
What I don't understand is why the event Transfer gets emitted but the transaction gets reverted? I suspect that's because I didn't transfer any wey, is that correct?

So ultimately I cannot transfer an unfungible token without payment?

en
ERC721
Ether
bfrascino80
18 days ago  Karma: 5
Can a ERC721 token be transferred without payment?

Hello all,

I'm learning solidity and I am testing some ERC721 functions. I wanted to test function setApprovalForAll() so what I did:

1 - Created 2 tokens (_mint())
2 - Did setApprovalForAll() authorizing an operator.
3 - Did safeTransferFrom(operator, a3rdUser, tokenId)
4 - Checked with ownerOf() if 'a3rdUser' now is the owner of the tokens.

I'm testing with ganache. The transaction gets reverted. It prints:

Events emitted during test:
```
---------------------------

Transfer(from: , to: , tokenId: )
Transfer(from: , to: , tokenId: )
ApprovalForAll(owner: , operator: , approved: true)

---------------------------
...

Error: VM Exception while processing transaction: revert
...
```

I noticed that the exception occurs when safeTransferFrom() is called because no code after that is reached in the test.
What I don't understand is why the event Transfer gets emitted but the transaction gets reverted? I suspect that's because I didn't transfer any wey, is that correct?

So ultimately I cannot transfer an unfungible token without payment?

en
ERC721
Ether

2 ANSWERS
1wolfer0
16 days ago Karma: 8

Well for one, yes you can't do any function call that changes state (like transferring a token) on Ethereum without paying some gas.

On Loom you can get away without paying gas for that function call, but to claim it on Ethereum you'll need gas.

That being said, I'm not 100% sure if your error was fee related as when using ganache, the transactions usually supply enough of a fee to make the transaction work. Please post your source code or ask in the telegram and I can try helping you further.

Well for one, yes you can't do any function call that changes state (like transferring a token) on Ethereum without paying some gas.

On Loom you can get away without paying gas for that function call, but to claim it on Ethereum you'll need gas.

That being said, I'm not 100% sure if your error was fee related as when using ganache, the transactions usually supply enough of a fee to make the transaction work. Please post your source code or ask in the telegram and I can try helping you further.

shaun_mcintyre
15 days ago Karma: 8

With regards to wei payment, you do pay gas fees (as someone else in this thread has already pointed out) but, there is no need to transfer an ERC721 token WITH payment. I highly suspect that there is an error or bug in your code somewhere that is causing execution to halt. If I may make a suggestion: make a bare bones implementation of your safetransferfrom() first. See if that works. Then start adding on the extra layers of complexity that make it "safe", one at a time and get those layers working before adding more. This is a tedious, and mind-numbing process, believe me I know! BUT when working with an unfamiliar language, or one as new as Solidity where there is somewhat limited debugging capabilities, this becomes a powerful way to isolate bugs. When you're done compare the code before and after, see what changed.

With regards to wei payment, you do pay gas fees (as someone else in this thread has already pointed out) but, there is no need to transfer an ERC721 token WITH payment. I highly suspect that there is an error or bug in your code somewhere that is causing execution to halt. If I may make a suggestion: make a bare bones implementation of your safetransferfrom() first. See if that works. Then start adding on the extra layers of complexity that make it "safe", one at a time and get those layers working before adding more. This is a tedious, and mind-numbing process, believe me I know! BUT when working with an unfamiliar language, or one as new as Solidity where there is somewhat limited debugging capabilities, this becomes a powerful way to isolate bugs. When you're done compare the code before and after, see what changed.

Earn tokens by posting and answering questions about blockchain!
Karma to eth
YOUR ANSWER