user6102
user6102

Reputation: 3

Ethereum deployed contract not defined in Geth Javascript console

I cannot access a deployed and mined Ethereum contract on a private network from the Geth Javascript console. Not sure where the issue is, any help is appreciated.

Thank you in advance for your time.

Scenario

I launched my Geth as below

geth --datadir ~/.ethereum/myProject --networkid 1234 --rpc --rpcport 8546 --rpcapi "eth,net,web3" --unlock 0 console

I've deployed and mined an Ethereum contract (to simplify things, I've used the default MetaCoin contract provided by Truffle), and I got the trx and contract address back. I can access it from the Truffle console but if I try from the Geth Javascript console I get an error.

Please refer to the pictures below:

Truffle console

Geth javascript console

Software used

Upvotes: 0

Views: 602

Answers (1)

Xavier Leprêtre
Xavier Leprêtre

Reputation: 136

Geth does not know about MetaCoin. In Geth console, you need to do:

var MetaCoin = web3.eth.Contract(metaCoinJsonAbi, itsAddress);
// or web3.eth.contract depending on the version of Web3

Then you can use it. Refer to this.

Upvotes: 1

Related Questions