0

I am trying to deploy my contract written in solidity on a test network (Rinkeyby),But when i run the command "node deploy.js" i get the mentioned error in the title of this article which is "RangeError:Maximum call stack size exceeded".I will be appreciated if someone helps with this issue :)

------------------------------------------------- deploy.js ------------------------------------------

const HDWalletProvider =  require("@truffle/hdwallet-provider");

const Web3 = require("web3");

const { interface, bytecode } = require("./compile");

const provider = new HDWalletProvider(
    "<MNEMONIC>",
    "https://rinkeby.infura.io/v3/<INFURA_ID>"
);

const web3 = new Web3(provider);

const deploy = async () => {
    const accounts = await web3.eth.getAccounts();

    console.log("Attempting to deploy from account", accounts[0]);

    const result = await new web3.eth.Contract(JSON.parse(interface))
      .deploy({ data: bytecode, arguments: ["Hi there Sina!"] })
      .send({ gas: "1000000", from: accounts[0] })

    console.log("Contract deployed to", result.options.address);
};

deploy()

------------------------------------------------- compile.js ------------------------------------------

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"];

------------------------------------------------- inbox.sol ------------------------------------------

pragma solidity ^0.4.17;

contract inbox {

    string public message;
    
    function Inbox(string initialMessage) public {
        message = initialMessage;
    }
    
    function setMessage(string newMessage) public {
        message = newMessage;
    }
}
1
  • 2
    It's probably not wise to post your infura key (df01291183a54c5ca4b4d1e3efd763b8) in public. – goodvibration Dec 24 '20 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.