4

Let's say I want to store an interface in EVM storage. Any idea how much this costs and how many slots of storage this takes up?

Is it cheaper to store an interface in contract storage or to create a new one every time in memory?

Example:

ERC20Interface BabyDoge = ERC20Interface('SOME_ADDRESS_HERE');
antioi
  • 61
  • 3

1 Answers1

2

I believe all contract references are stored as just address. This includes references created through an interface. So the storage is very cheap.

All the functionality you get when you explicitly have a typed contract (instead of a simple address) is just nice extra you get from the language. In reality, for the bytecode to be generated, all the calls to external contracts are converted to low-level calls.

You can read more about low-level calls for example here: https://artmoneyprovenance.com/2021/08/05/how-to-use-low-level-call-for-contract-function-calls-and-payments-in-solidity/

Lauri Peltonen
  • 29,391
  • 3
  • 20
  • 57