Is there a cut-off where a variable name uses more memory? For instance:

uint public priceOfEthYesterday9AMUSAET


uint public pEth

One is more descriptive, but if it's costing me gas I don't want to do this.

  • 1
    No (as in any other language). It might take the preprocessing part of compilation to take slightly longer, but that's it. Oh wait, it'll also take Etherscan slightly longer to render it on the web-page when you view your contract's function (more precisely, the web-page text size will be slightly longer hence could take slightly longer to arrive from the server to your client). And there's a bunch of other similar side-effects, but the binary code (as well as every subsequent aspect of runtime behavior) stays the same. Dec 13, 2019 at 17:52

3 Answers 3


The name of a variable does not affect gas usage.

In this case, you are using a uint, so the gas for this variable is already defined by that size. All STOREs performed on this will behave the same no matter the length of the variable name.


The length of a variable name has absolutely 0 effect on gas, and therefore transaction fee.

The length of a function name also has no effect on the transaction fee, because a 4 byte hash of the function name and its parameter types is used to select the correct function to execute, instead of the full function name.


The name of the function/variable indeed affects the gas cost. (And for a large contract with many functions/variables it can make a difference of 1000 gas.) What might be sagnificant if the function is being called many times over.

However that difference in function cost is not due to length of its name, but rather due to the "order of 4 byte hash of the function's name". (Please read the article linked below for detail explanation)


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.