# Comparison of gas cost in different types of data storage

I want to compare gas fee of different types of data includes: String, bytes, uint, bool, int, address and etc... does anyone knows how much they costs? or share a link about this? Thank you

Here is a rough estimate of the gas cost for various data types in Ethereum:

Storing data:

``````Bool: 3 gas
Int (256-bit): 20 gas per word
Str: 20 gas per word
Bytes: 20 gas per word
``````

Arithmetic operations:

``````Add: 3 gas
Sub: 3 gas
Multiply: 5 gas
Divide: 5 gas
``````

Bitwise operations:

``````AND: 3 gas
OR: 3 gas
XOR: 3 gas
NOT: 3 gas
Shift: 3 gas
``````

Comparison operations:

``````<: 3 gas
<=: 3 gas
>: 3 gas
>=: 3 gas
==: 3 gas
!=: 3 gas
``````

https://ethereum.github.io/yellowpaper/yellowpaper.pdf

or you can refer to this pdf it contains all the technical info of ETH Blockchain

• And what's difference between storing uint256 or unit 8 ,bytes and etc? Commented Feb 4, 2023 at 11:11
• A uint256 requires 32 bytes of storage and a uint8 requires 1 byte of storage. Storing a smaller data type will be less expensive than storing a larger data type. uint256 can store a larger range of values than uint8 but requires 32 times more storage. Commented Feb 4, 2023 at 11:19
• It means that if i store 1 byte in a uint256, it's equal to store 1 byte in uint8?? Commented Feb 4, 2023 at 11:31
• It's not the same. A `uint256` variablecan store a value between `0 and 2^256-1`, while a `uint8` variable can store a value between `0 and 2^8-1`. If you store `1 byte` of data in a `uint256`, you are using `256 bits` of storage space, while storing the same data in a `uint8` uses `8 bits` of storage space Commented Feb 4, 2023 at 11:39
• Hope this make it more clear btw the difference of `uint256` and `uint8` Commented Feb 4, 2023 at 11:41