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 '19 at 17:52

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.