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