This question already has an answer here:

I am getting this error while compiling the contract using solc:

assert.js:350 throw err; ^enter code here AssertionError [ERR_ASSERTION]: Invalid callback specified

This is my deploy.js file....

let fs = require('fs');
let solc = require('solc');
let Web3 = require('web3');

let contract = compileContract();
let web3 = createWeb3();
let sender = '0x...';

deployContract(web3, contract, sender)
        console.log('Deployment Finished')
    .catch(function (error) {
        console.log('Failed to deploy contract: ${error}')

    function compileContract() {
        let compilerInput = {
            'Voter': fs.readFileSync('Voter.sol', 'utf8')

        console.log('Compiling the contract')
        // Compile and optimize the contract
        let compiledContract = solc.compile(compilerInput, 1);

        // Get compiled contract
        let contract = compiledContract.contracts['Voter:Voter'] // Voter contract from Voter file.

        // Save contract's ABI
        let abi = contract.interface;
        fs.writeFileSync('abi.json', abi);

        return contract;

    function createWeb3() {
        let web3 = new Web3();
            new web3.providers.HttpProvider('http://localhost:8545')

            return web3;

    async function deployContract(web3, contract, sender) {
        let Voter = new web3.eth.Contract(JSON.parse(contract.interface));
        let bytecode = '0x' + contract.bytecode;
        let gasEstimate = await web3.eth.estimateGas({data: bytecode});

        console.log('Deploying the contract');
        const contractInstance = await Voter.deploy({
            data: bytecode
            from: sender,
            gas: gasEstimate
        .on('transactionHash', function(transactionHash) {
            console.log('Transaction hash : ${transactionHash}');

        .on('confirmation', function(confirmationNumber, receipt) {
            console.log('Confirmation number: ${confirmationNumber}');

        console.log('Contract address: ${contractInstance.options.address}');

marked as duplicate by Ismael, shane, Richard Horrocks, Nicolas Massart, Briomkez Jan 3 at 20:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • version of solc? – Aniket Dec 28 '18 at 11:03

Browse other questions tagged or ask your own question.