1

I am getting the below message:

,Warning: Contract code size is 28837 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.

I think it is due to:

function fetchPatientProfile(PatientProfileData storage self, address key) internal view returns (Patient memory) {
    Patient memory patientProfile = self.patientProfiles[key]; // get value
    return patientProfile;
}

Is there a better way to create a fetch from storage variable?

I'm creating profiles from the below function, which calls a library:

function createPatientProfile(Patient calldata profile) external onlyOwner {
    require(patientProfiles.addPatientProfile(profile));
}

1 Answer 1

0

Here is a good link that might help. https://ethereum.org/en/developers/tutorials/downsizing-contracts-to-fight-the-contract-size-limit/

NOTE: Make sure you are using solidity optimizer.

2
  • I separated the functions into library, but what if the library is now exceeding the size?
    – kpatel23
    Mar 9, 2023 at 21:10
  • You can have two or more libraries (External Libraries)
    – Sky
    Mar 10, 2023 at 8:34

Your Answer

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

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