I'm trying to deploy my smart contract that compiled without any problem and stored all the compiled data in two separate files. Then I'm requiring the ABI and bytecode and tries to deploy it. I get the following error.
1) "before each" hook for "deploys a factory and campaign":
TypeError: this._deployData.startsWith is not a function
at Object._encodeMethodABI (node_modules\web3-eth-contract\lib\index.js:456:31)
at Object._processExecuteArguments (node_modules\web3-eth-contract\lib\index.js:713:39)
at Object._executeMethod (node_modules\web3-eth-contract\lib\index.js:732:68)
at Context.<anonymous> (test\projectFund.test.js:24:6)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
This is my test.js file
const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const compiledFactory = require('../EthereumProject/build/projectFundFactory.json')
const compiledFund = require('../EthereumProject/build/ProjectFund.json');
let accounts;
let factory;
let campaignAddress;
let campaign;
beforeEach(async()=>{
accounts = await web3.eth.getAccounts();
factory = await new web3.eth.Contract(compiledFactory.abi)
.deploy({ data: compiledFactory.evm.bytecode })
.send({ from: accounts[0], gas:'1000000' }); //the above error points here
await factory.methods.createProjectFund('100').send({
from: accounts[0],
gas: '1000000'
});
[ campaignAddress ] = await factory.methods.getDeployedProjectFund().call();
campaign = await new web3.eth.Contract(
compiledFund.abi,
campaignAddress
);
});
describe('Campaigns', ()=>{
it('deploys a factory and campaign', ()=>{
assert.ok(factory.options.address);
assert.ok(campaign.options.address);
});
});