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.

ERC777 change visibility of some attributes and methods from private to internal

See original GitHub issue

🧐 Motivation I’m trying to extend the base ERC777 contract to be pauseable, but ran into an issue. The best way I can think of to accomplish this is to override _move(), _mint() and _burn() to check if the contract is paused, but _move()'s visibility is private, so it can’t be overridden. I’d also like to create setter methods for _name and _symbol but can’t because they are private also.

šŸ“ Details I’m wondering what the rationale is for making methods/attributes private and if it’s okay to change some of them to internal, namely move(), _name and _symbol. I’ll submit a pull request if there are no objections.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
frangiocommented, Nov 8, 2019

a scenario where a function is pausable without us realizing it because it indirectly moves tokens around.

Wouldn’t this be desirable though? I would expect that if I pause the contract all moving is paused.

I still don’t think exposing _move is a good idea anyway.

My proposal is to make the ERC777 interface functions public rather than external as they are now. This allows people to override them to add functionality and to create new external functions that make use of them.

2reactions
frangiocommented, Nov 6, 2019

Hi @JonahGroendal! Your use case sounds quite reasonable!

Unfortunately though, we do have a strict policy of keeping all variables private.

Rather than forking, I would highly encourage you to inherit the contract, create the 2 extra variables, and add overrides. I agree that it sounds messy, but it’s more aligned with the recommended way to use the library. It’s highly discouraged to fork and modify the code for yourself because you can accidentally introduce bugs, and even though this particular case is harmless, when it comes to security conventions it’s better to strictly follow them always.

Similarly to the private variables, I think _move is too low-level a function for us to safely expose internally. Unfortunately you won’t be able to modify send and transfer through overrides either because they’re external and super.send will not compile. This is a shortcoming of our current implementation that we should fix. We closed things down as much as possible initially to keep our options open, to see what features users would need and what would be the best interface we can provide for them. Apologies that you ran into these issues!

@nventuro what do you think we should do here to enable the implementation of a Pausable ERC777?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Smart Contracts and Dapps: From Theory to Practice
Private – Like internal visibility, but the function cannot be accessed from related deriving contracts. Functions Behavior. The pure, constant,Ā ...
Read more >
rICO | ConsenSys Diligence
tokenAddress: The address of the ERC777 token used in the rICO ... This address can change the rICO address when the token is...
Read more >
Chapter 10: Tokens Ā· GitBook
Another proposal for an improved token contract standard is ERC777. This proposal has several goals, including: To offer an ERC20-compatible interface. ToĀ ...
Read more >
arXiv:2107.02997v1 [cs.CR] 7 Jul 2021
At first glance, re-entrancy might seem inapplicable to ERC-20 however any function that changes internal state, such as balances, need to be.
Read more >
Solidity 201 - by Rajeev | Secureum
Function Overriding Changes: The overriding function may only change the visibility of the overridden function from external to public.
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