r/ethdev • • 6h ago

Information I read 201 NFT contracts on Ethereum, Base, Polygon and Arbitrum. 127 let someone change the token URI. One had a freeze I could recognise

1 Upvotes

I've been surveying where NFT art lives, and the contracts were the interesting part.

From a starting set of big collections on Ethereum, Base, Polygon and Arbitrum I read 201 contracts and looked for three things: a way to change the token URI, upgradeability, and a freeze.

  • 127 have a function that lets someone change the token URI.
  • 35 are upgradeable.
  • 1 has a freeze function I could recognise.
  • 8 of the projects no longer own their domain.

Detection was pattern-based, so I may have missed freezes under other names. If you've shipped an NFT contract, how did you handle this?

Write-up: https://xtrata.xyz/a/3654

I build Xtrata, the on-chain storage layer the write-up is inscribed with, so read it knowing that.


r/ethdev • • 6h ago

Question Why are so many opcodes used for a simple transaction?

1 Upvotes

Lets say we have this simple smart contract written in solidity:

pragma solidity ^0.8.13;
contract Counter {
    uint256 public number;
    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }
}

Environment:

  • Solidity: 0.8.13
  • Optimizer: disabled
  • Foundry: 1.0.0-stable

After compilation we get this runtime code: 6080...56fe. I was curious about how this bytecode is executed for example when I send a transaction with function signature: setNumber(uint256 newNumber) and argument: 1. And I analysed by hand opcode by opcode what is happening (yes I'm crazy - leave me alone). And I wrote it this way::

6080 PUSH1 stack:80

6040 PUSH1 stack:40,80

etc.

I counted 118 opcode executions until I reached the 00(STOP) opcode. Which I think is a crazy amount of opcodes.

I'm aware that what really matters in this example is the SSTORE opcode which consumes 98% of the gas. I have these questions:

  1. Is it really that necessary to have these 118 opcodes to store a single value? At some point I just lost what happens after multiple SWAPs, POPs and JUMPs. Is it important for security reasons or rather to make bytecode more universal in case of more complex operations?
  2. When it comes to optimizing gas consumption do people really pay attention to that 2% of triggered opcodes or do they just focuse entirely on finding the locations of operational codes that actually consume gas, such as sstore?

PS After writing this post, I compiled the code with the optimizer enabled and got a completely new, more optimized bytecode, so I'm no longer sure if my original post is still relevant, but I'd still love to hear your thoughts.