Hey, guys. I need to fill big array (5000-10000 elements) in my smart-contract, and I'm trying to find the cheapest way.

What's the reason for such big gas units difference in these two options on the screenshot? It's cheaper to iterate through calldata and push values to storage array, rather than assigning it in one line.

Sep 3, 2022, 7:22 PM
What's your usage?
Sep 3, 2022, 7:23 PM
I need to know NFTs rarities inside of my smart-contract. So there're around 7000 NFTs and each of them has rarity. So I wanted to fill array/mapping inside of my smart-contract.
Contract with NFTs is already deployed. I'm writing a staking contract for it. And to reward user with tokens, I need to know rarities of the tokens they've sent to stake.
Sep 3, 2022, 7:25 PM

© 2024 Draquery.com All rights reserved.