I have installed solC module with command:

npm install solc

How can I use this module in Geth?

When I execute var solc = require("solc") in Geth's console, interpreter throws:

Error: Cannot find module 'solc'
at s (web3.js:1:160)
at s (web3.js:1:122)
at <anonymous>:1:12

you will not use var solc = require("solc") in geth but in nodejs. for example, creat a test.js file and copy inside the following code :

var solc = require('solc');
var input = "contract x { function g() {} }";
var output = solc.compile(input, 1); // 1 activates the optimiser
for (var contractName in output.contracts) {
    // code and ABI that are needed by web3
    console.log(contractName + ': ' + output.contracts[contractName].bytecode);
    console.log(contractName + '; ' + JSON.parse( output.contracts[contractName].interface));

then run it using node test.js you will get a result like :

:x: 60606040523415600e57600080fd5b5b607d8061001d6000396000f300606060405263ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663e2179b8e8114603c575b600080fd5b3415604657600080fd5b604c604e565b005b5b5600a165627a7a72305820ae6d537ab5d046202257892d26e5771413caeae62c0c9c574cf610f3e86179110029
:x; [object Object]

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.