1

In the BAT token contract:

https://etherscan.io/address/0x0d8775f648430679a709e98d2b0cb6250d2887ef#code

What is the purpose of declaring the contract "Token" (in which just the functions are declared) and just after creating another contract which inherits from "Token":

contract StandardToken is Token {...}

Why not just declaring AND defining all functions in one contract ?

1 Answer 1

2

The Token contract where just the methods are declared are referred to as interface contracts. These work in similar fashion to interfaces in traditional OOP world.

Abstract contract implementation using interfaces helps avoid cross compilation errors and also used to decouple inter contract communication.

These abstract contracts are only provided to make the interface known to the compiler. Interfaces are basically limited to what the Contract ABI can represent, and the conversion between the ABI and an Interface should be possible without any information loss.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.