smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.67k stars 2.89k forks source link

code size to deposit exceeds maximum code size #1884

Open demos2022 opened 10 months ago

demos2022 commented 10 months ago

// 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

xyz899 commented 10 months ago

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