I run the following simple contract
var greeterSource = '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; } function greet() constant returns (string) { return greeting; } }'
var greeterCompiled = web3.eth.compile.solidity(greeterSource)
var _greeting = "Hello World!"
var greeterContract = web3.eth.contract(greeterCompiled.greeter.info.abiDefinition);
var greeter = greeterContract.new(_greeting,{from:web3.eth.accounts[0], data: greeterCompiled.greeter.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);
}
}
else
{
console.log(e);
}
})
and get the following output
Contract transaction send: TransactionHash: 0xd4b3b0e627e54d0c847fe4379a910b5a4cbc883269d88e6964a68e6e6042f30c waiting to be mined...
Contract mined! Address: 0x06b805ac3b28faed4560f2c4a01b1f988644df12
{ _eth:
{ _requestManager: { provider: [Object], polls: {}, timeout: null },
getBalance: { [Function] request: [Function], call: 'eth_getBalance' },
getStorageAt: { [Function] request: [Function], call: 'eth_getStorageAt' },
getCode: { [Function] request: [Function], call: 'eth_getCode' },
getBlock: { [Function] request: [Function], call: [Function] },
getUncle: { [Function] request: [Function], call: [Function] },
getCompilers: { [Function] request: [Function], call: 'eth_getCompilers' },
getBlockTransactionCount: { [Function] request: [Function], call: [Function] },
getBlockUncleCount: { [Function] request: [Function], call: [Function] },
getTransaction: { [Function] request: [Function], call: 'eth_getTransactionByHash' },
getTransactionFromBlock: { [Function] request: [Function], call: [Function] },
getTransactionReceipt: { [Function] request: [Function], call: 'eth_getTransactionReceipt' },
getTransactionCount: { [Function] request: [Function], call: 'eth_getTransactionCount' },
call: { [Function] request: [Function], call: 'eth_call' },
estimateGas: { [Function] request: [Function], call: 'eth_estimateGas' },
sendRawTransaction: { [Function] request: [Function], call: 'eth_sendRawTransaction' },
sendTransaction: { [Function] request: [Function], call: 'eth_sendTransaction' },
sign: { [Function] request: [Function], call: 'eth_sign' },
compile: { solidity: [Object], lll: [Object], serpent: [Object] },
submitWork: { [Function] request: [Function], call: 'eth_submitWork' },
getWork: { [Function] request: [Function], call: 'eth_getWork' },
coinbase: [Getter],
getCoinbase: { [Function] request: [Function] },
mining: [Getter],
getMining: { [Function] request: [Function] },
hashrate: [Getter],
getHashrate: { [Function] request: [Function] },
syncing: [Getter],
getSyncing: { [Function] request: [Function] },
gasPrice: [Getter],
getGasPrice: { [Function] request: [Function] },
accounts: [Getter],
getAccounts: { [Function] request: [Function] },
blockNumber: [Getter],
getBlockNumber: { [Function] request: [Function] },
iban:
{ [Function]
fromAddress: [Function],
fromBban: [Function],
createIndirect: [Function],
isValid: [Function] },
sendIBANTransaction: [Function] },
transactionHash: '0xd4b3b0e627e54d0c847fe4379a910b5a4cbc883269d88e6964a68e6e6042f30c',
address: '0x06b805ac3b28faed4560f2c4a01b1f988644df12',
abi:
[ { constant: false,
inputs: [],
name: 'kill',
outputs: [],
type: 'function' },
{ constant: true,
inputs: [],
name: 'greet',
outputs: [Object],
type: 'function' },
{ inputs: [Object], type: 'constructor' } ],
kill:
{ [Function]
request: [Function],
call: [Function],
sendTransaction: [Function],
estimateGas: [Function],
getData: [Function],
'': [Circular] },
greet:
{ [Function]
request: [Function],
call: [Function],
sendTransaction: [Function],
estimateGas: [Function],
getData: [Function],
'': [Circular] },
allEvents: [Function] }
Now how can i access the functions please give guide to me
I run this line on terminal and geth console but i got the error
greeter.greet();
the error is
ReferenceError: 'greeter' is not defined
at <anonymous>:1:13
So please help anyone to fix this problem if i do anything wrong please mention it
or give the example link