I'm almost done with my contract but I've done (almost) everything to reduce the byte size of my contract and I'm still missing like two features. That's why I need to split the contract in order to reduce size even more. I've already extracted a part of my code into two other contracts. Bar is abstract and will be extended by my main contract and Baz will be initialized and called from the main contract. Example:
contract Foo extends Bar {
Baz baz;
constructor() {
baz = new Baz();
}
}
That worked out but my contract size didn't really decrease. Should I inject Baz instead of initializing it on the main contract? How would I do that since something like that
contract Foo extends Bar {
Baz baz;
constructor(address barAdress) {
baz = address;
}
}
will throw Type address is not implicitly convertible to expected type contract Baz. obviously.
Does an extended abstract contract even reduce the byte code or will it be combined in compilation and result in the same size?
Does an extended abstract contract even reduce the byte code or will it be combined in compilation and result in the same size?
The compiler still needs to include the abstract contract, so it doesn't reduce the final bytecode size.
An effective way to reduce the bytecode size is to use the compiler optimization option. The value specifies the number of the contract runs that it should optimize for (not the number of optimization iterations). So lower values will result in smaller bytecode but also higher gas fees each time you're executing a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With