1
  1. "before each" hook for "deploy contract": Eip1559NotSupportedError: Invalid value given "Eip1559NotSupportedError". Error: Network doesn't support eip-1559.

This is my Inbox.sol code:

// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

contract Inbox {
string public message;

constructor(string memory initialMessage) { 
    message=initialMessage;
}

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

This is my compile.js code:

const path = require('path');
const fs = require('fs');
const solc = require('solc');
const { stringify } = require('querystring');


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

// console.log(solc.compile(source,1));

var input = {
language: 'Solidity',
sources: {
    'Inbox.sol' : {
        content: source
    }
},
settings: {
    outputSelection: {
        '*': {
            '*': [ '*' ]
        }
    }
}

};

module.exports =                 
JSON.parse(solc.compile(JSON.stringify(input))).contracts['Inbox.sol']        
['Inbox'];

console.log(module.exports);

this is my Inbox.test.js code:

const assert = require('assert'); 
const ganache = require('ganache-cli');
const { Web3 }  = require('web3'); 
const web3 = new Web3(ganache.provider());
const{abi, evm} = require('../compile');



let accounts;
let inbox;

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

inbox = await new web3.eth.Contract(abi)
.deploy({
    data: evm.bytecode.object,
    arguments: ['Halo']
})
.send({ from: accounts[0], gas: '1000000' });
});

describe('Inbox', () => {
it('deploy contract', () =>{
    console.log(inbox);
})
})

And finally this is my package.json :

{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
"test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
"@truffle/hdwallet-provider": "^2.1.12",
"assert": "^2.1.0",
"asset": "^0.4.13",
"ganache": "^7.8.0",
"ganache-cli": "^6.12.2",
"mocha": "^10.2.0",
"solc": "^0.8.19",
"web3": "^4.3.0"
  }
}

I don't know what went wrong, I already ask chatgpt and it said I have to deactivate EIP-1559 by typing in cmd " ganache-cli --noVMEIP1559" or " ganache-cli --eip1559 false". But both are written "Unknown argument: noVMEIP1559"

2 Answers 2

2

I had the same problem for days.You can add to your code "gasPrice" as below

inbox = await new web3.eth.Contract(abi)
.deploy({
    data: evm.bytecode.object,
    arguments: ['Halo']
})
.send({ from: accounts[0], gas: '1000000',gasPrice:1000000000 });
});
1
  • This will solve the issue but I agree with @Do-do-new. It is best to upgrade to hardhat. Commented Oct 2 at 15:49
1

I assume you are following somewhat outdated tutorial (probably on Udemy).

You are using ganache-cli package, which is outdated, and starts networks prior to even London hardfork.

To get it to work you can either add gasPrice as @petros-rodinos suggested, or use ganache package instead of ganache-cli, and use London (or newer hardfork), than instead of gasPrice you would have to add maxFeePerGas and maxPriorityFeePerGas, like so:

.send({from: accounts[0],  gas: '1000000',
        maxFeePerGas: web3.utils.toWei('5', 'gwei'),
        maxPriorityFeePerGas: web3.utils.toWei('3.5', 'gwei') 
        })

But now even Ganache is obsolete, so I recommend switching to Hardhat, otherwise you won't be able to use newer compiler version (see. e.g this issue)

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.