full-blockchain-solidity-course-py icon indicating copy to clipboard operation
full-blockchain-solidity-course-py copied to clipboard

code size to deposit exceeds maximum code size

Open demos2022 opened this issue 2 years ago • 1 comments

// SPDX-License-Identifier: MIT

pragma solidity 0.6.0; contract SimpleStorage { uint256 favoriteNumber; // This is a comment! struct People { uint256 favoriteNumber; string name; } People[] public people; mapping(string => uint256) public nameToFavoriteNumber;

function store(uint256 _favoriteNumber) public {
    favoriteNumber = _favoriteNumber;
}

function retrieve() public view returns (uint256){
    return favoriteNumber;
}
function addPerson(string memory _name, uint256 _favoriteNumber) public {
    people.push(People(_favoriteNumber, _name));
    nameToFavoriteNumber[_name] = _favoriteNumber;
}

}

This is my contract I get this error message - alueError: {'message': 'VM Exception while processing transaction: code size to deposit exceeds maximum code size', 'stack': 'RuntimeError: VM Exception while processing transaction: code size to deposit exceeds maximum code size\n at LegacyTransaction.fillFromResult

If I remove all the functions from my contract, my transaction goes through

demos2022 avatar Aug 07 '23 21:08 demos2022

Hello,

Given the contract, it shouldn't exceed the EVM maximum code size limit, especially if you are deploying on Remix.

One possibility is the pragma version. You're using Solidity version 0.6.0; have you tried updating to a more recent version or confirming that all your dependencies are compatible with this version?

Here's how you can specify a newer version in your contract:

pragma solidity ^0.8.0;

Also, try deploying the contract on Remix IDE for debugging purposes. If it deploys successfully there, the issue could be specific to your local environment or the method you're using for deploying it.

Looking forward to your update.

FrostX

xyz899 avatar Aug 28 '23 08:08 xyz899