7

I want to collect user data and store it on the blockchain. Let's say I need to store usernames. Is the cost of storing 1 byte on the blockchain different for contract storage/log data/transaction input?

manidos
  • 4,298
  • 3
  • 31
  • 55

1 Answers1

12

Contract storage is the most expensive at generally 20,000 gas for each 32 bytes (which is 1 storage slot).

Logs cost 375 gas for a LOG operation. 375 gas for each topic. 8 gas for each byte of a LOG operation's data. See Ethereum event log maximum size for more information.

Transaction input costs 4 gas for a zero byte, and 68 gas for a non-zero byte.

Important consideration: Does the data need to be accessible directly by contracts? If so, contract storage is the only option: contracts can't directly access logs or other transactions.

eth
  • 85,679
  • 53
  • 285
  • 406