I'm writing a contract for an ERC-20 token, and I've been trying to optimize for gas (since the fees are ridiculous at the moment).
I was wondering if instead of using a string, I could use a bytes32 for the token metadata, and if it would still be able to read the name on etherscan, and anywhere else my token might be registered.
I would be changing from this:
string public constant name = ".....";
string public constant symbol = "...";
string public version = "1.0";
to this:
bytes32 public constant name = bytes32(".....");
bytes32 public constant name = bytes32("...");
bytes32 public version = bytes32("1.0");
I've already tested the two versions, and the second one does save on a lot of gas. Just wondering if I'll run into issues later because of this.
Thanks!
contract.name()
. Of course, front-ends are going to check this and run into issues. Just to be clear, I'm against this proposal, and was trying to say that the gas savings is only going to be one time and might not be worth the hassle in the end.