Using libraries to reduce contract-size?

Hi @dan-i , in the project I am working on, I keep bumping up against the contract size limit all the time.
I found this:
and have used all the methods to the degree I’m able, but now it’s looking like the next step is using libraries, but my contract just gets even bigger when moving functions over to a library.
And as I have understood, making the functions public will not include them in the main contract when I compile, but looks like it does that anyway when using truffle to test everything.
I will very much appreciate any help on the matter or tips on where to find a solution
thank you! :blush:

Hey @voljumet

Do you mind to share your git repo so that I can take a look?


here is my repo:
“main” and “Libbie” are the branches that I’m comparing to see if I can reduce the size

Hey @voljumet

I was able to deploy by just cloning your repo :smiley:
Screenshot 2021-04-08 at 11.56.23

Where exactly is it failing for you?

Can you include screenshots?

Also which version of truffle are you running?

Hey, that’s great :blush:
the version is as shown in the picture below v5.2.3.
Everything works for me too, if I keep many of the functions in the project that are commented that way (as comments, so they won’t get deployed).
And this is where the issue is, if I want to have those functions deployed, the project gets too big to be deployed and I get this:
Screenshot 2021-04-08 at 12.20.25
The problem does not go away if I adjust the gas limit in Ganache to 20721975.

So the main thing I want to do is use “Libbie.sol” as a library, so the functions inside “Libby.sol” do not get included in the of the project and uses all the gas.
But I have no idea how to include functions from a library