Skip to content

Instantly share code, notes, and snippets.

@OnahProsperity
Created November 29, 2021 20:27
Show Gist options
  • Save OnahProsperity/7d678d308a6ae47dc149d755054f20f9 to your computer and use it in GitHub Desktop.
Save OnahProsperity/7d678d308a6ae47dc149d755054f20f9 to your computer and use it in GitHub Desktop.
Enum as a interface and used in other contract
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;
interface interEnum {
enum SIDE {
buy,
sell
}
}
contract B is interEnum {
function bEnum(SIDE side) external {
// do something with here
}
}
contract A {
B b;
enum NUM {
buy,
sell
}
function bEnum(NUM num) external {
// i cant pass in an enum from here.
// invalid explicit conversion from uint256 to Enum when i tried it this way
// b.bEnum(uint256(num);
// b
// invalid explicit conversion from enum to enum....
// b.bEnum(num);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment