1

I've been trying to get a simple contract deployed on ganache with web3.js. Here is my test code :

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

let accounts;
let myContract;

before(async function() {

    accounts = await web3.eth.getAccounts()

    myContract = await new web3.eth.Contract(abi)
        .deploy({data: "0x" + evm.bytecode.object, arguments: []})
        .send({from: accounts[0], gas: 5000000});

    console.log("finished")

});
// describe and it part....

The error is : Callback was already called : at ....../ganache-cli/build/lib.node.js:22953:36

Anybody got any idea? Thanks a lot

  • The before clause is not executed when there are no it clauses, so there cannot be any error here. Please share the relevant code, and indicate exactly which line is throwing the given error. – goodvibration Apr 24 at 5:42
  • actually there is an "it" clause right where i spotted ( commented out). the problem is with send method. the moment it gets called booom.. Error : Callback was already called – ramd Apr 24 at 5:50
  • How do you know it's in the send method, when it is appended to two other function calls preceding it (new and deploy)? – goodvibration Apr 24 at 5:52
  • Of course i don't know for sure. But the result of deploy is just a TransactionObject with some method on it (send, call,...). I'm guessing the issue is raised when the real sending is happening so there has to be some sort of callback.!!!! – ramd Apr 24 at 5:56
  • I've been following this link : medium.com/coinmonks/…. Except using async/await – ramd Apr 24 at 5:58
0

Change your node version I have seen this error before you need to set to compatible version in my case it was v12.

https://cryptoyaks.com/callback-was-already-called-ganache/

| improve this answer | |

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.