-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Benefits of using abstract contracts #627
Comments
I don't think it has any relation to gas costs. Abstract contracts are a counterpart of the JSON ABI definition in Solidity. |
The main benefits of an abstract contract are:
|
^this should be documented. |
In C++, one can create a pure virtual interface that forces uses inheriting from a class to implement certain functions. Is there a similar idea in Solidity? If yes, this should be documented. If no, what happens to a smart contract that presents an interface in an abstract contract, but then does not implement that interface in the derived contract? This should be documented. Also--I know it is possible to derive a smart contract from two different abstract contracts (token plus safe math, for example). What happens in the case of a function signature conflict? This should be documented as well. |
@tjayrush Solidity's interfaces are documented here: https://solidity.readthedocs.io/en/develop/contracts.html#interfaces Solidity's inherited signature collision is documented here: https://solidity.readthedocs.io/en/develop/contracts.html#inheriting-different-kinds-of-members-of-the-same-name |
I'm unfortunately finding little efficiency with Interfaces. Abstract getters aren't recognised as implemented by public state variables. So I end up just using the abstract contract model with public state declared there rather than using private state with explicit getters. |
@o0ragman0o In C++, you would have to implement a separate getter in the derived class, so that makes a bit of sense to me. I guess the point you're making is due to the automatic nature of setters/getters? It seems to me that, without the data in the abstract class, there wouldn't be an automatic generation of setters/getters. But in any case, to get back to the issue, this behaviour should be documented as well. A summary of above issues so far: benefits
questions
watch outs
|
It can be forced at compile time, if that's what you mean by forcing. Btw. ERC-20 tokens is a good example of an actual interface that people are using. Look at that standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md Notice how it not only states that the contract should contain this and that, but also offers some actual interface contract that can be used by developers. Solidity also provides an interface in the standard contracts (Token.sol in the std folder). |
I think there needs to be added documentation on the benefits of utilizing abstract contract functions...Is there not a cheapening of gas that comes with using an abstract contract? I may be wrong but I think it does. Either way...the documentation doesn't really give a reason why I would want to use an abstract contract or when I would want to...this could be improved.
The text was updated successfully, but these errors were encountered: