Skip to content

TypeError: Cannot read property 'stopWatching' of undefined #11

Description

@wighawag

Here is a nodejs script that i execute via node script.js

var Web3 = require('web3');
var web3 = new Web3(); 

var EtherSim = require('ethersim'); 
var sim = new EtherSim.init();
web3.setProvider(sim.provider);

//getting bytecode and ABI...

sim.reset();
sim.createAccounts(10, function() {
    sim.setBalance(web3.eth.accounts[0], 123450000, function() {
        web3.eth.getAccounts(function(err, accs) {
            var TestContract = web3.eth.contract(ABI);
            TestContract.new({
                from: web3.eth.accounts[0],
                gas : 3000000,
                data: bytecode
            }, function(err, deployedContract){
                console.log(deployedContract);
                //sim.mine() //should be required to get address?
                var transactionReceipt = web3.eth.getTransactionReceipt(deployedContract.transactionHash);

                console.log(transactionReceipt.contractAddress);
                //sim.reset(); never ends
            });
        });
    }); 
});

I get the following error :

/vagrant/node_modules/web3/lib/web3/contract.js:128
                            filter.stopWatching();
                                  ^

TypeError: Cannot read property 'stopWatching' of undefined
    at Object.callback (/vagrant/node_modules/web3/lib/web3/contract.js:128:35)
    at /vagrant/node_modules/web3/lib/web3/method.js:142:25
    at /vagrant/node_modules/web3/lib/web3/requestmanager.js:89:9
    at /vagrant/node_modules/ethersim/lib/manager.js:60:7
    at Manager.eth_getCode (/vagrant/node_modules/ethersim/lib/manager.js:110:10)
    at Manager.request (/vagrant/node_modules/ethersim/lib/manager.js:64:19)
    at TestProvider.sendAsync (/vagrant/node_modules/ethersim/lib/provider.js:11:23)
    at RequestManager.sendAsync (/vagrant/node_modules/web3/lib/web3/requestmanager.js:80:19)
    at Eth.send [as getCode] (/vagrant/node_modules/web3/lib/web3/method.js:141:42)
    at Object.callback (/vagrant/node_modules/web3/lib/web3/contract.js:122:39)

if I uncomment the last sim.reset() node hang

any idea?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions