enums in solidity solidity enum

The solution for “enums in solidity solidity enum” can be found here. The following code will assist you in solving the problem.

contract MyEnums {

enum Rarity {
original, // 0
rare, // 1
super_rare // 2
}

Rarity public rarity;

constructor() {
rarity = Rarity.rare;
}

function makeSuperRare() public {
rarity = Rarity.super_rare;
}
}enum EnumType { Value1, Value2, Value3 }

EnumType MyEnum;
MyEnum = EnumType.Value1;

// uint8(EnumType.Value1) => 0
// uint8(EnumType.Value2) => 1
// uint8(EnumType.Value3) => 2

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts