Issue with compiling Solidity code: RangeError - Exceeded maximum call stack size limit

I am currently enrolled in a course on Solidity by Stephen Grider, which I found on this platform. I'm encountering issues with using compile.js to compile my Solidity code. My setup includes node.js version 12.18.3, solc version 0.4.25, and npm version 6.14.16.

Here is the snippet of the compile.js code:

const path = require('path');
const fs = require('fs');
const solc = require('solc');

const inboxPath = path.resolve(__dirname, 'contracts', 'Inbox.sol');
const source = fs.readFileSync(inboxPath, 'utf8');

module.exports = solc.compile(source, 1).contracts[':Inbox'];

Check out the Course here

Snippet from Inbox.sol:

pragma solidity ^0.4.25;

contract Inbox {
    string public message;

    function Inbox(string initialMessage) public {
        message = initialMessage;
    }

    function setMessage(string newMessage) public {
        message = newMessage;
    }
}

Encountering this error while trying to compile:

RangeError: Maximum call stack size exceeded
    at Object.$db [as dynCall_viiiiii] (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[24m\soljson.js:12:120931)
    at invoke_viiiiii (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4mso
lc←[24m\soljson.js:1:1118207)
    at Array.pva (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:13:29030)
    at Object.M9a [as dynCall_vi] (C:\Users\iluka\Desktop\Solidity\Inbox\node_mo
dules\←[4msolc←[24m\soljson.js:12:99033)
    at invoke_vi (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:1:1115011)
    at Array.xta (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:10:704784)
    at Object.Dfb [as dynCall_iii] (C:\Users\iluka\Desktop\Solidity\Inbox\node_m
odules\←[4msolc←[24m\soljson.js:12:130740)
    at invoke_iii (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[
24m\soljson.js:1:1119442)
    at Array.vta (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:10:703080)
    at Object.Yfb [as dynCall_iiiiii] (C:\Users\iluka\Desktop\Solidity\Inbox\nod
e_modules\←[4msolc←[24m\soljson.js:12:131900)

Answer №1

I encountered a similar issue and found a solution that worked for me.

First, uninstall solc by running npm uninstall solc

Then install it again using npm install --save [email protected]

Answer №2

To optimize performance, it may be beneficial to downgrade the module versions in the package.json file and then run npm install. The code snippet shown above is functioning correctly with the specified dependencies:

  "dependencies": {
    "ganache-cli": "^6.12.2",
    "mocha": "^8.4.0",
    "solc": "^0.4.26",
    "web3": "^1.0.0-beta.26"
  }

Answer №3

During my experience, I had mistakenly utilized

pragma solidity ^0.4.17;

as well as

constructor() public {...}

instead of defining the function with

Lottery() public{...}

It is important to note that if you are working with solc version 0.4.25 or later, using constructor() is acceptable. Otherwise, you might encounter errors such as "RangeError: Maximum call stack size exceeded" and "Cannot destructure property 'interface' of 'require(...)' as it is undefined".

I encountered these issues specifically when executing mocha tests.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Extract data from nested JSON and populate a list with corresponding values

<ul> <li><a href="" class="edit">a unique item in the list</a></li> <li><a href="" class="edit">another unique item in the list</a></li> <li><a href="" class="edit">yet another unique ...

Transferring a large volume of JSON objects to a database using API post requests

Currently, I'm faced with the challenge of sending a large amount of JSON objects to a database through API post calls. However, upon attempting to send all these objects individually, I encounter numerous HTTP errors, predominantly 400 errors. My in ...

Return the information from Node.js to the JavaScript on the client side

My goal is to establish a fetch connection from client-side JS to the server Node.JS. When a person clicks on a button in HTML, it triggers a search in the MongoDB database on the server side. Once the element is found, I am unsure how to send that informa ...

Using the `.animate()` function in JavaScript causes a one-second delay

I'm encountering some difficulties with the .animate() function in Javascript. I'm using it to automatically scroll to an element within a div, which is functioning correctly. However, I am facing an issue where the scrolling freezes for a second ...

Leverage PHP to integrate JSON data for consumption by JavaScript

I've been exploring the integration of React (JavaScript) within a WordPress plugin, but I need to fetch some data from the database for my plugin. While I could retrieve this data in JavaScript using jQuery or an API call, because the data will remai ...

Having trouble with uploading images using Form.File in React?

I'm facing an issue with my React code for uploading an image. It doesn't seem to be working and I can't figure out why. Can someone please assist me? return ( <div> <FormContainer> <h1>Edit Product& ...

Adjust website content depending on user's authentication status

My goal is to display a logout button when the user is logged in and a login button if they are not. I am using JSON tokens to determine if a user is logged in or not, by checking if the token is null. However, this approach does not seem to be working. Ca ...

Is there a way to deactivate the click function in ngx-quill editor for angular when it is empty?

In the following ngx-quill editor, users can input text that will be displayed when a click button is pressed. However, there is an issue I am currently facing: I am able to click the button even if no text has been entered, and this behavior continues li ...

creating dynamic navigation tabs with scroll functionality

Utilizing Bootstrap Nav Tabs and Tab panes on my website has been a smooth process. However, I am encountering some difficulty in adding extra links that not only activate the Tab Panes but also scroll to them. The issue seems to be related to a specific l ...

Which is the better choice for simply invoking a service method - subscribe or toPromise?

When implementing the search method below, I simply assign the value of BehaviourSubject in the service. However, I am unsure whether it is possible to execute this operation without using either subscribe() or toPromise() after the .pipe() block in the ...

Tips for positioning input fields and labels in both horizontal and vertical alignment

Below is the HTML code, and I want the tags to look like this: label1: input1 label2: input2 label3: input3 Instead, it currently looks like this: label1: input1 How can I modify the HTML to achieve the desired format? HTML: <div class=" ...

When you delete a property from a duplicated version of an Object in JavaScript, it ends up impacting the original Object as

Let's imagine we have an array of objects, var data = [{ "sss": "sssssss", "yyy": "ssdsdsds", "www": "1212121", "Group": "Mango" }, { "sss": "sssssss", "yyy": "ssdsdsds", "www": "1212121", "Group": "Mango" }] The desi ...

Aggregating quantities of various items using Redux

I'm in the process of setting up a shopping cart using Redux. Essentially, my React code retrieves product details from a database and displays them for the user. Below is a snippet of my App.js: function GetProductsHtml() { initProducts() con ...

Looking to incorporate multiple accordion drop down menus on your website? Utilize a combination of HTML, CSS, and JavaScript to

I am experiencing a challenge with implementing multiple accordion menus on my website. Whenever I attempt to duplicate the code, the new accordion menu appears but clicking on the first bar simply scrolls me back to the top of the webpage. Below is the H ...

Can you explain the function of v-bind within Vue?

I recently started learning Vue and decided to follow a video tutorial by Traversy Media on Youtube In the tutorial, the instructor used v-bind but I struggled to understand its usage. Despite my efforts, I still find the documentation a bit challenging ...

Reveal or Conceal Information Depending on Cookie Status

Below is the Jquery code I am using: $("#tool").click(function() { $(".chelp").slideToggle(); $("wrapper").animate({ opacity: 1.0 },200).slideToggle(200, function() { $("#tool img").toggle(); }); }); When the #tool img is clicked, bot ...

Is RxJS more suitable than Redux/context for handling and accessing state in various components and handler methods?

Redux is commonly seen as an improved version of Flux, simplifying application state management. Although I have heard about reactive programming (RxJS), I have yet to explore it myself. My query is: do Redux and RxJS share any similarities or are they c ...

What sets cross-fetch apart from isomorphic-fetch?

According to the Redux documentation, cross-fetch is the preferred choice, whereas most other sources recommend using isomorphic-fetch. What sets these two apart? ...

Toggle classes upon clicking the body using JavaScript

I've been using the Filter Everything plugin for WooCommerce and made some customizations, but I'm still experiencing issues with the JavaScript. When I click to filter, it opens the list but doesn't close when I click outside of the box. T ...

How can we know when a JavaScript ES6 arrow function comes to a close?

One thing I've been pondering is how an arrow function terminates when it lacks brackets. I encountered this issue when working with ReactJS, where I had a function followed by the start of a class declaration. Here's the snippet: const Search = ...