Geth console can’t access smart contract

0 votes

I have created a Smart contract in truffle and deployed it in Ethereum private network. I am running MetaCoin box which I download from truffle official website.

I started my network using the following command:

geth --datadir ./myDataDir --networkid 1234 --rpc --rpcport 8546 --rpcapi "eth,net,web3"

Now I have entered the geth console but whenever I run any commands related to MetaCoin, I get error telling it is not defined:

> MetaCoin.at(<address>).address
ReferenceError: ‘MetaCoin’ is not defined
Jan 27 in Blockchain by Neeraj
78 views

1 answer to this question.

0 votes

You are running commands using an object that you have not defined (MetaCoin). So when you run the above command, geth does not know what you are talking about. Before running the command, you need to create an object of MetaCoin. Run the below command and then you won’t get the error:

var MetaCoin = web3.eth.Contract(metaCoinJsonAbi, itsAddress);
answered Jan 27 by Omkar
• 67,660 points

Related Questions In Blockchain

0 votes
1 answer

How to access member functions of smart contract using web3?

I have implemented a similar feature and ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,170 points
85 views
0 votes
1 answer

Can't call contract function in truffle console

Inspect the object adoption within the console. You will ...READ MORE

answered Sep 28, 2018 in Blockchain by slayer
• 29,170 points
693 views
+1 vote
1 answer

How is a smart contract stored on a Blockchain?

Smart contract template and transaction events are ...READ MORE

answered Apr 4, 2018 in Blockchain by Christine
• 15,790 points
162 views
+1 vote
1 answer

Can we copy a smart contract?

While the contract is open-source, if you ...READ MORE

answered Apr 6, 2018 in Blockchain by Christine
• 15,790 points
70 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
169 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,660 points
101 views
0 votes
1 answer
+1 vote
4 answers

How to estimate the cost for deploying smart contract on mainnet?

Since you have already deployed the contract ...READ MORE

answered Apr 9, 2018 in Blockchain by Shashank
• 10,350 points
1,544 views
+1 vote
2 answers

Can I include real world data in a smart contract? If so, how?

You cant access/embed real world data using ...READ MORE

answered Jul 17, 2018 in Blockchain by sapan
71 views