4

I have a contract that compiles in browser solidity and solc. Using either the auto-generated deployment code in browser solidity or my own npm version, I end up with the error

"myContract.new" is not a function.

This, as I understood it, is a function intrinsic to the Contract type, since it's required for deployment. When I do console.log(myContract) I get

[Function: bound Contract].

When I try to deploy,there is an extremely unhelpful error message / random code output as well:

 node_modules/solc/soljson.js:1 (function (exports, require, module,
 __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var
 key i
 Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var
 ENVIRONMENT_IS_WEB=typeof window==="object";var
 ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var
 ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof
 require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var
 ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function
 print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function
 printErr(x){process["stderr"].write(x+"\n")};var
 nodeFS=require("fs");var
 nodePath=require("path");Module["read"]=function
 read(filename,binary){filename=nodePath["normalize"](filename);var
 ret=nodeFS["readFileSync"](filename);if(!re
  • 1
    Can you rename your contract to something other than contract or Contract? Just to make sure you are not using reserved words. – Xavier Leprêtre B9lab Sep 13 '16 at 11:35
3

Make sure you are using the proper version of web3 for js.

For example, ethereum.js appears to be outdated

So make sure your javascript script begins with:

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

not

var web3 = require('ethereum.js');

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.