I have been working on creating a guide to port Solidity smart contracts to ink! smart contracts. I was hoping for some input on how to best handle Solidity's uint256 in ink!.

Solidity is optimized for 256 bit / 32 byte words. So, many Solidity smart contracts use uint256 as a way to save on gas (but not necessarily storage). ink! does not have a u256 built in. To me, it seems like the size of a u128 (largest primitive numerical type in ink!) would be more than sufficient to represent most non-hash numerical values.

So, I am thinking that the proper route for this is to reduce the uint256 to a more appropriate size in ink!. Or if absolutely necessary, create a wrapper around a [u64; 4].

Does this seem like an appropriate approach? Also, are there any similar word-size optimizations for ink! / Wasm?

1 Answer 1


Answer from @alexander-theißen:

The biggest primitive type in wasm is 64bit cause this is what real computers have (ignoring simd stuff). So there is no value in using u128 over a collection.

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.