0

I'm reading docs on Venom and they said that the problem on using mapping in ERC20 contract is "Now let's imagine that we have an erc-20 like mem-token contract with one large hashmap of token holders. Everyone who has ever bought this token will be recorded in this contract. Eventually, we will have a situation where users with large balances will have to pay for the storage of those who have only pennies left on their accounts."

I understand is that if mapping get bigger then access mapping will cost more gas ? But i think it is not true because access and storage have same gas. Anyone can explain me why they said that? Thanks for your time

4
  • Can you provide the document where it is mentioned as a problem? Currently in Ethereum storage costs are paid once, and the content will be persisted forever. There were some proposal to charge for storage more dynamically. If after some time you want o keep using it you have to pay otherwise it will be deleted.
    – Ismael
    Sep 3, 2023 at 0:22
  • 1
    @Ismael Hello, I also think as same as you. I'm reading Venom chain, it is a distributed and asynchronous blockchain and this quote is said on their docs when they develop new token standard (TIP-3) from ERC20 (venom.guide/smart_contracts/distributed_programming, on Paid Storage section and I see other articles from Venom on Medium, etc with the same meaning)
    – dang.pm.IT
    Sep 3, 2023 at 9:15
  • The documents compares how ERC20 will behave with Venom storage costs. In that context frequent users need to pay the costs for the other users, otherwise the contract will be frozen and the token will lose its value.
    – Ismael
    Sep 3, 2023 at 21:36
  • @Ismael I reread it and I misunderstanding the meaning of that quote. Thanks for your time
    – dang.pm.IT
    Sep 4, 2023 at 7:27

1 Answer 1

-2

You asked a good question, the difference is that both reading and writing consume gas in mapping

3
  • I don't understand what you mean ? Both read and write is access on position: Let say you have a mapping (uint256 => uint256) counts The storage position of one item will be keccak256(keccak256(abi.encode(counts.slot(get from assembly), uint256(key))). I think it doesn't have any effect on gas
    – dang.pm.IT
    Sep 2, 2023 at 18:09
  • In fact, it is meant during the initial deployment of the smart contract that a large mapping can have a higher cost, otherwise, after deploying and reading with a function, there is no cost. You are right.
    – Mehran Ra
    Sep 2, 2023 at 18:47
  • Thank you! Hope you have a nice day
    – dang.pm.IT
    Sep 2, 2023 at 18:52

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.