Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Added more information
Source Link
mcansado
  • 841
  • 1
  • 8
  • 25

I'm trying to load another version of solc using the following code

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var solc = require('solc');
var fs = require('fs');
// getting a legacy version 
const input = fs.readFileSync('contracts/Token.sol').toString();

solc.loadRemoteVersion('0.4.4+commit.4633f3de.Darwin.appleclang', function(err, solcV044) {
    if (err) {
        // An error was encountered, display and quit
    }

    var output = solcV044.compile(input);
    console.log(output);
});

but am getting an error TypeError: solc.loadRemoteVersion is not a function and I am not understanding why, what am I missing?

EDIT: Not sure what this means but may help identify the issue. When I console.log(solc) I get back

{ version: [Function],
  compile: [Function: compile],
  useVersion: [Function: useVersion] }
/Users/mcansado/node_modules/solc/bin/soljson-latest.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in 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

I'm trying to load another version of solc using the following code

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var solc = require('solc');
var fs = require('fs');
// getting a legacy version 
const input = fs.readFileSync('contracts/Token.sol').toString();

solc.loadRemoteVersion('0.4.4+commit.4633f3de.Darwin.appleclang', function(err, solcV044) {
    if (err) {
        // An error was encountered, display and quit
    }

    var output = solcV044.compile(input);
    console.log(output);
});

but am getting an error TypeError: solc.loadRemoteVersion is not a function and I am not understanding why, what am I missing?

I'm trying to load another version of solc using the following code

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var solc = require('solc');
var fs = require('fs');
// getting a legacy version 
const input = fs.readFileSync('contracts/Token.sol').toString();

solc.loadRemoteVersion('0.4.4+commit.4633f3de.Darwin.appleclang', function(err, solcV044) {
    if (err) {
        // An error was encountered, display and quit
    }

    var output = solcV044.compile(input);
    console.log(output);
});

but am getting an error TypeError: solc.loadRemoteVersion is not a function and I am not understanding why, what am I missing?

EDIT: Not sure what this means but may help identify the issue. When I console.log(solc) I get back

{ version: [Function],
  compile: [Function: compile],
  useVersion: [Function: useVersion] }
/Users/mcansado/node_modules/solc/bin/soljson-latest.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in 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
Source Link
mcansado
  • 841
  • 1
  • 8
  • 25

solc.loadRemoteVersion is not a function error

I'm trying to load another version of solc using the following code

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var solc = require('solc');
var fs = require('fs');
// getting a legacy version 
const input = fs.readFileSync('contracts/Token.sol').toString();

solc.loadRemoteVersion('0.4.4+commit.4633f3de.Darwin.appleclang', function(err, solcV044) {
    if (err) {
        // An error was encountered, display and quit
    }

    var output = solcV044.compile(input);
    console.log(output);
});

but am getting an error TypeError: solc.loadRemoteVersion is not a function and I am not understanding why, what am I missing?