1

From solidity docs:

Free functions are always internal functions and are meant to replace internal library functions and their very special behaviour.

How do free functions differ from libraries? Libraries use DelegateCall and I've read somewhere that DelegateCalls are more expensive to run for the first call (haven't seen this in testing though) to prevent DoS attacks — so are free functions cheaper?

I'm also curious to learn if there is a difference in the context of contract upgradability

1 Answer 1

2

In the case of a library that is inherited, your contract will never delegatecall to it. It will rather be added as a contract with internal functions, because delegatecall would be more expensive. If you wish to use a library by calling it externally, you need to specify his address.

Free functions, while very similar to libraries when used in an inherited state, have more functionalities. As you can see, they allow having to state, payable functions, ... Which libraries don't allow because they have initially been designed to be called externally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.