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?