2

I use metamask with chrome. In console browser when I run this code

var source = "" + 
    "contract test {\n" +
    "   function multiply(uint a) returns(uint d) {\n" +
    "       return a * 7;\n" +
    "   }\n" +
    "}\n";
var compiled = web3.eth.compile.solidity(source, function(err,res){
  console.log(err);
  console.log(res);
})

I have this error :

Error: Error while compiling code.(…)

Is it a way to compile and deploy a smart contract directly in the the console browser ?

1

You definitely can compile solidity from MetaMask.

MetaMask passes that content to its hosted RPC for compilation, in this case, a Parity node.

In this case, the error message is not quite ideal, and I'll open a bug on MetaMask for that.

Opening the MetaMask background process, I found the error being thrown by Parity is "No such file or directory", and I'm not sure why that would be thrown, this is a strange error to get for some solidity code, I'd recommend asking the Parity team for a more descriptive error.

To get the full output, you can run this in your console to simulate the same call to the backend:

curl -X POST  -H "Content-Type: application/json"  --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"],"id":1}' https://morden.infura.io

Where you can replace morden.infura.io with your own parity node if you'd like.

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.