I have a contract A
, which has an instance of contract B
, i.e., B b
.
Contract A
calls a function of contract B
via the instance, i.e., b.func()
.
Contract B
is stateless, i.e., no global non-constant variables.
I therefore decided to redeclare it as a library
.
After that, when I compile contract A
, I get the following error:
TypeError:
Member "func" not found or not visible after argument-dependent lookup in type(library B)
I can resolve the problem by changing the access-level of func
from external
to internal
.
However, that prevents me from calling the function via Web3
(Python).
Can someone please explain this odd behavior, i.e., why do I need to reduce the function's access-level from external
to internal
after I "reduce" the contract
to a library
?
UPDATE:
I think I got it:
The library
code is "embedded" into the contract
which imports it (like a macro in C if you will).
Then, only functions that are either private
, internal
or public
can be invoked from inside the contract, while external
functions can be invoked only from outside the contract.
So my question really is:
How can I reconcile the fact that I want these functions to be internal
when used by a contract, and external
when accessed via Web3
(for testing purpose)?
Thank you!