I read some about Libraries restriction that 'No state variables'

but, some solidity code's Libraries have struct type.

As far as I know that(may be wrong) struct type is 'storage' and 'state variables' are values which are permanently stored in contract 'storage'.

so, struct type is 'state variable'?

I'm confused.

1 Answer 1


A struct is just a type.

struct Foo {
    string bar;

There are no state variables yet because no variables have been declared. All I did is define a type.

If I do this:

uint256 myNumber;
Foo myStruct;

now I have two state variables, both existing in storage. One is a uint256, and one is a Foo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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