Skip to content

Instantly share code, notes, and snippets.

@cleanunicorn
Created September 2, 2022 11:12
Show Gist options
  • Save cleanunicorn/fb6462a4ca19091a663d797966d73833 to your computer and use it in GitHub Desktop.
Save cleanunicorn/fb6462a4ca19091a663d797966d73833 to your computer and use it in GitHub Desktop.
The order of inherited contracts matters
pragma solidity 0.8.16;
contract BaseOne {
event ExecutedBaseOne();
function overrideMe(
) public virtual {
emit ExecutedBaseOne();
}
}
contract BaseTwo {
event ExecutedBaseTwo();
function overrideMe(
) public virtual {
emit ExecutedBaseTwo();
}
}
contract Instance is BaseOne, BaseTwo {
function overrideMe()
public
override(
BaseOne,
BaseTwo
) {
// Which one is called
// BaseOne.overrideMe() or BaseTwo.overrideMe() ?
super.overrideMe();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment