question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve clarity of error messages in functions checking token ownership

See original GitHub issue

🧐 Motivation Good morning folks. I feel this somewhat walks the line between feature and bug.

While extending some .*transfer() functionality in the OpenZeppelin contracts (thank you for providing them!) I found some of my tests failing due to an error reading:

ERC721: transfer caller is not owner nor approved

As a newcomer, most of the terminology of ownership in documentation and in the “higher level” contracts refers to the contract owner - with frequently used modifiers like onlyOwner and the Ownable contract reinforcing this. I spent quite some verifying that the test was indeed making calls with the owner’s signature, and that signature matches the .owner() in the instance of the contract under test.

After delving in a little more I found that the term “owner”, in this context, refers to the token owner.

(A more dramatic reading of this experience as at the bottom for those interested in such things)

📝 Details A small amount of clarification may go a long way to saving others the journey I went on myself, for example extending the error message to

ERC721: transfer caller is not *token* owner nor approved

I have a PR ready with this, and for all similar instances of such messages. Thank you for your consideration.

Dramatic Reading

“But I am the owner”, I whinge at the test suite, exhausted. In red, emblazoned in the flickering terminal: “‘ERC721: transfer caller is not owner nor approved’” stands its ground - repeatedly unconvinced of my ownership. I checksum, and I verify. The messages are signed with poise, grace, and cryptographic correctness. The deployer is requesting the transfer. The very deployer that is also the current owner of this fine establishment. So I dig. I fear I’ll dig too greedily and too deep, and awaken something in the darkness. “Ah.” I sigh. Owner can mean owner of the contract, but this “owner” refers to a check of owner of the token. So let this fable guide you all - don’t reuse curt terminology for something that is already overloaded. All this could have been avoided with a simple “ERC721: transfer caller is not token owner nor approved”.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kanedaaaacommented, Mar 9, 2022

Haha, yes I can send one.

0reactions
frangiocommented, Mar 7, 2022

@kanedaaaa I like that! Do you want to submit a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a SIP010 fungible token - Clarity Book
A static function that returns a human-readable symbol for our token. (define-read-only (get-symbol) ...
Read more >
Error Handling In Rust - A Deep Dive - A learning journal
We are trying to insert a row into the subscription_tokens table in order to store a newly-generated token against a subscriber_id . execute...
Read more >
Storj Token Audit - OpenZeppelin blog
The Storj team asked us to review and audit their new Storj Token (STORJ) code. We looked at their contracts and now publish...
Read more >
Building an NFT with Stacks and Clarity - Developer DAO
Stacks, and its smart contract programming language, Clarity, ... parameter being passed to the function, otherwise we return the err-not-token-owner error ...
Read more >
6. Fungible Tokens | Flow Blockchain
Instead of representing token ownership in a central ledger smart ... is another feature that Cadence uses to improve the clarity of code....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found