Let's say I have multiple smart contracts that inherit from one base contract:
Contract Base{
function doSomething(){};
}
Contract A is Base{
}
Contract B is Base{
}
What I want to do is call doSomething without knowing which particular contract I'm dealing with, just having the address.
instance = web3.eth.contract(BaseABI).at(givenAddress);
instance.doSomething();
I believe that is polymorphism (correct me if I'm wrong). So, is that possible ? Just to be clear, the givenAddress
can be the address of a contract A, B or any other contract that's been deployed and that inherits from Base
. I want to be able to retrieve an instance of that contract without giving the specific ABI, just the Base
one, since all I want to do in this case is calling the the Base doSomething
.
Thank you for your advice.
PS: I did try that (with testrpc) which gives me an invalid op code
.
web3.eth.contract
andat
methods are implmented) In this case, polymorphism isn't really implemented on Ethereum yet... I'd like a better insight if possible.