Compiling in solc, deploying in geth - how do you do it?

silly_nsilly_n Member Posts: 7

How do you deploy contracts in geth console, which you compiled from command line solc?

Here's what I'm currently doing and I'm stuck, getting errors:

1. getting ABI to files: mortal.abi, greeter.abi:
~solc --abi greeter.solc -o out

2. compile to files: mortal.bin, greeter.bin
~solc --bin greeter.solc -o out

3. modify mortal.abi: embrace content with "var srcMortal = ''" so I can use srcMortal inside geth console

4. modify mortal.bin: embrace content with "var comMortal=''" again so I can use it inside geth console

5. load in geth:
> loadScript("mortal.abi")
> var ctxMortal = web3.eth.contract(srcMortal)
> loadScript("mortal.bin")
6. try to deploy:
>var mortal ='hello',{from:web3.eth.accounts[1], data: comMortal, gas: 500000}, function(e, contract){
        if(!e) {
        if(!contract.address) {
         console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
        } else {
         console.log("Contract mined! Address: " + contract.address);
        }        }        })
This procedure always gives me an error:
TypeError: 'filter' is not a function
at encodeConstructorParams (<anonymous>:-72188:-408)
at new (<anonymous>:-77460:-408)
at <anonymous>:1:14
The contract compiles and runs perfectly if I do it in geth with: web3.eth.compile.solidity(srcMortal) and deploy it. I'm getting the same error with any contract I've tried.

What am I doing wrong? What is the best practice to do this?

Version: 1.4.0-unstable
Protocol Versions: [63 62 61]
Network Id: 1
Go Version: go1.5.1
OS: linux


  • kl3eokl3eo Member Posts: 1
    === a working code for deploying and interacting with a greeter contract from the geth console and using offline solc: (much of it taken from Gustavo

    echo "var greeOutput=`solc --optimize --combined-json abi,bin,interface gree.sol`" > gree.js

    geth console

    var greeContractAbi = greeOutput.contracts['gree.sol:greeter'].abi
    var greeContract = eth.contract(JSON.parse(greeContractAbi))
    var greeBinCode = "0x" + greeOutput.contracts['gree.sol:greeter'].bin
    var deployTransactionObject = { from: eth.accounts[0], data: greeBinCode, gas: 1000000 };


    var greeInstance ='hola, chicos!', deployTransactionObject)


    var greeAddress = eth.getTransactionReceipt(greeInstance.transactionHash).contractAddress

    var gree =;

    gree.set_hello_string.sendTransaction('hola, chicas!', {from: eth.accounts[0], gas: 1000000})


    gree.set_hello_string.sendTransaction('hola, todo el mundo!', {from: eth.accounts[0], gas: 1000000})


    gree.kill.sendTransaction({from: eth.accounts[0]})

Sign In or Register to comment.