The below is my inbox.test.js file code:

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

let accounts; let inbox;

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

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


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

    it("sets the contract message", async () => {
        await inbox.methods
          .setMessage("test message")
          .send({ from: accounts[0], gas: "1000000" });


The error is as follows:

Inbox 1) "before each" hook for "deploys a contract"

0 passing (233ms) 1 failing

  1. "before each" hook for "deploys a contract": Web3ContractError: The number of arguments is not matching the methods required number. You need to pass 0 arguments.

    at encodeMethodABI (node_modules\web3-eth-contract\src\encoding.ts:190:9) at getSendTxParams (node_modules\web3-eth-contract\src\utils.ts:75:26) at ContractBuilder._contractMethodDeploySend (node_modules\web3-eth-contract\src\contract.ts:1062:29) at Object.send (node_modules\web3-eth-contract\src\contract.ts:608:17) at Context. (test\inbox.test.js:16:13) at processTicksAndRejections (node:internal/process/task_queues:95:5)

Please help me with this. This is my first ever smart contract.

1 Answer 1


This error might happen when you invoke deploy() with arguments.length > 0. You could try passing the following to the deploy method: { data: bytecode, arguments: [] }.

Alternatively, try running your code in Debug mode and inspect where the error is thrown.

  • Thankyou sooo much.
    – Swetha N
    Jun 21, 2023 at 6:16
  • now it shows this error: "before each" hook for "deploys a contract": c: VM Exception while processing transaction: invalid opcode at Function.c.fromResults (node_modules\ganache-cli\build\ganache-core.node.cli.js:4:192416) at w.processBlock (node_modules\ganache-cli\build\ganache-core.node.cli.js:42:50915) at processTicksAndRejections (node:internal/process/task_queues:95:5)
    – Swetha N
    Jun 21, 2023 at 6:22

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.