I'd like to store the amount of ether sent to a contract.

I thought I could use the data type 'wei' but apparently that doesn't compile. Ex:

wei public someBalanceVar;
wei public someBalanceVar2;

What is the best way to store value denominated in wei?

2 Answers 2


Use uint256. It's just a number.


There is no data type called wei in solidity. You can use uint (for unsigned integer) and prefix by number that can hold max bits (256 or less)

In your case use uint256: After changing your code with

 uint256 public someBalanceVar;
 uint256 public someBalanceVar2;

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.