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');

1 Answer 1

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/

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.