0

In Ethereum transactions, you can use the Data field to send text. Here's an example testnet transaction.

https://ropsten.etherscan.io/tx/0x19e4921d572e7f513954c9dada66d7e4fb01d91b5c09be840b235c9fae73401e

If I understand correctly, the gas cost increases incrementally for each 256 bit hex word.

How many UTF-8 characters can you fit in each 256 bit hex word?

1
  • Some initial research - it seems like each 256 bit hex word can hold 64 hex characters, which would be equivalent to 32 UTF-8 chars. But this is pieced together from multiple sources so I am not confident yet
    – tjr226
    May 5 at 19:22
0

UTF-8 characters have a minimum size of 1 byte, so assuming the smallest size per character, you can fit at most 32 characters (= 32 bytes = 256 bits). The size per character can go up to 4 bytes however, so it depends on what exactly you're trying to send.

If I understand correctly, the gas cost increases incrementally for each 256 bit hex word.

This only applies if you're using the Solidity ABI format for transaction data, since those values are encoded per 32 bytes. If you just send arbitrary bytes in a transaction, the data is not padded to form groups of 32 bytes. The gas cost for every 0-byte is 4 gas, and for every non-0-byte is 68 gas, so the total gas for a transaction (assuming there are no contracts involved) can be calculated as follows:

21,000 + (4 × <number of 0-bytes>) + (68 × <number of non-0-bytes>)

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.