I tried deploying a greeter contract as shown here , I thought the deployment is suceess but i am unable to get the address of the contract, it always shows undefined.
When I tried to execute the greet method it also shows undefined
pls check the attached image.
- geth version 1.5.3-stable-978737f5
- solidity version - 0.4.6
I also did unlocking the account and waited for over 10 mins to let it mine.
below are the steps I did to compile and deploy the contract.
var greeterSource1 = 'contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) selfdestruct(owner); } } contract greeter1 is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }'
var greeterCompiled1 = web3.eth.compile.solidity(greeterSource1)
var _greeting1 = "Hello World!"
var greeterContract1 = web3.eth.contract(greeterCompiled1.greeter1.info.abiDefinition)
var greeter1 = greeterContract1.new(_greeting1,{from:web3.eth.accounts[0], data: greeterCompiled1.greeter1.code, gas: 300000},
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);
console.log(contract);
}
}
})