I am new to the dApp development. I want to deploy a contract to Ethereum through a website i am building. However i don't want the user to do it through the solidity online compiler or mist wallet. I want the user to press a button and the contract to automatically deploy on the Ethereum (backend function). I am using meteor for this project. Any suggestions on how to implement something like that? Thank you

  • 1
    Have you had a look at deployment from NodeJs? ethereum.stackexchange.com/questions/7255/… Jan 31, 2017 at 11:52
  • Yes I have. Let me show you an example of what i am trying to do. var source = "" + "contract demo {\n" + " string public name = 'Petros';\n" + " function changeName(string _newName){\n" + " name = _newName;\n" + " }\n" + "}\n"; var compiled = web3.eth.compile.solidity(source, function(err,res){ //necessary callback function console.log(compiled); }); console.log(compiled); However the code doesn't appear to compile and nothing shows in the console
    – PetrosM
    Jan 31, 2017 at 16:41
  • Make your Solidity source code as a one line string. Plus, why do you console.log(compiled) if it is res that you get? Jan 31, 2017 at 17:10
  • Yes i tried the source code in one line string. yea i should have written console.log(res) which does return an object with too many options that i don't understand. However there is still the problem that console.log(compiled); in the end won't return anything. I can't find a way to interact to interact with the returned res object. i.e. how can i retrieve the string "petros" from the contract i deployed?
    – PetrosM
    Jan 31, 2017 at 19:57

1 Answer 1


Can you run this in Geth console?

> var source = "contract demo { string public name = 'Petros'; function changeName(string _newName){ name = _newName; }}";

> var compiled = web3.eth.compile.solidity(source);

> web3.eth.compile.solidity(source, function(err, res) { console.log(JSON.stringify(res)); });

The ABI will be compiled.demo.info.abiDefinition.

If you make an asynchronous call in Javascript, then what you get is in the callback, it is not in the returned thingy.

So this does not work:

var thisWillBeUndefinedObviously = web3.eth.compile.solidity(source, function(err, res) { console.log(JSON.stringify(res)); });
  • Ok so my return would be console.log(JSON.stringify(res)) from the callback function got it. However it doesn't show anywhere the contract address or abi so i can retrieve my string later. Also i wasn't using geth. deployed a couple of contracts through mist and solidity-metamask. I downloaded it, first command you told me to run was undefined and the second is still syncing the blockchain
    – PetrosM
    Feb 1, 2017 at 11:38
  • I edited my answer to tell you where is the ABI you missed. Compilation is one step. After, you need to deploy your contract, which gives you an address. The commands I gave you return undefined because they create variables. Call these variables to see what they have. Javascript 101. When you deployed through Mist, it did compile and deploy in 1 step. Feb 1, 2017 at 16:56
  • Ok I think i am on the right track now. Thanks for your help!
    – PetrosM
    Feb 1, 2017 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.