I wrote a contract greeter and mortal, they are as follows:

contract mortal {

    address owner;

    function mortal() { owner = msg.sender; }

    function kill() { if (msg.sender == owner) selfdestruct(owner); }

contract greeter is mortal {

    string greeting;

    function greeter(string _greeting) public {
        greeting = _greeting;

    /* main function */
    function greet() constant returns (string) {
        return greeting;

Then i compiled the code using Solidity online compiler. I copied the compiled code and pasted in a text file with name "helloworld.js" as follows:

var _greeting = /* var of type string here */ ;
var greeterContract = web3.eth.contract([
  {"constant":false,"inputs": [], "name":"kill", "outputs":[], "payable":false, "type":"function"}, 
  {"constant":true, "inputs": [], "name":"greet", "outputs":[{"name":"", "type":"string"}], "payable":false, "type":"function"},
  {"inputs": [{"name":"_greeting", "type":"string"}], "type":"constructor"}]);

var greeter = greeterContract.new(_greeting, 
    from: web3.eth.accounts[0], 
    data: 'data (some numbers and alphabets)', 
    gas: 4700000
  }, function (e, contract) {
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
      console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);

I went to the cmd and started my blockchain network. In geth console i unlocked my account with etherbase and used loadScript("C:/Rahul13615/blockchain/node1/contracts/helloworld.js")

Ideally it should return: Contract mined! address: some address

but it returns:

loadScript("C:/Rahul13615/blockchain/node1/contracts/helloworld.js") null [object Object] true

What should i do?


1 Answer 1


I posted this question a week ago and with the help of my peers i was able to solve it. The detailed answer is as follows:

Step 1:

Using the following command start your private blockchain network( change the data directories and other parameters according to your custom settings)

geth --identity "node1" --rpc --rpcport "8000" --rpccorsdomain "*" --datadir     "C:\Rahul13615\blockchain\node1" --port "30303" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 100 --nat "any"

Leave this terminal as it is (but do not close it) after executing the above command.

Step 2

Open another terminal and type:

geth attach

This will open the geth console. Now you must have created few accounts. We will set etherbase for any one account and execute script using it's address. So enter the following commands.

primary = eth.accounts[0]
>true (this is the output of above command)


personal.unlockAccount(primary,"passphrase") //here passphrase is the string you used while creating an account


Now in helloworld.js i have saved the compiled code that i copied from online browser solidity compiler. Change the first line of code to:

var _greeting = "Hello World" ;

Save helloworld.js and run the following command

>null [object Object]
Contract mined! Address : someAddress, Txhash : somevalue

>Hello World


Please comment for any doubts or questions.

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.