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;


    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(


describe('Campaigns', ()=>{
    it('deploys a factory and campaign', ()=>{

1 Answer 1


I think you are not passing in your bytecode right. You are missing the bytecode object - compiledFactory.evm.bytecode.object.

So it should look like this:

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

Hope this helps!

  • Thanks! it worked for me
    – Adil Nehal
    Dec 5, 2021 at 20:36
  • Thank you, it worked! Dec 6, 2021 at 2:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.