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

1 Answer 1


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 
Address: 20 gas
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


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?
    – Alireza
    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.
    – AmariS1
    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??
    – Alireza
    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
    – AmariS1
    Commented Feb 4, 2023 at 11:39
  • Hope this make it more clear btw the difference of uint256 and uint8
    – AmariS1
    Commented Feb 4, 2023 at 11:41

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.