Variable declaration problem in truffle console

0 votes

I am trying to run a smart contract in truffle. In truffle console when I try to declare a variable, it says “undefined”. I have compiled and deployed the contract with no errors but don’t know what’s wrong. This is what I tried:

truffle(default)> var poe = ProofOfExistence1.deployed()
Jan 27, 2019 in Blockchain by Shreya
1,270 views

1 answer to this question.

0 votes

The reason it says “undefined” is because the variable is not declared and initiated properly. The reason for this is that when you use .deployed(), this returns a Promise and the command you are running ca not use Promise object. Instead, try the following command:

truffle(development)> ProofOfExistence1.deployed().then(function(a) { poe = a; })
answered Jan 27, 2019 by Omkar
• 69,220 points

Related Questions In Blockchain

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,370 points
3,094 views
0 votes
1 answer

How to create an instance of contract in Truffle console?

Hi, @There, I would suggest you go through ...READ MORE

answered Jun 17, 2020 in Blockchain by Gitika
• 65,770 points
2,020 views
+1 vote
1 answer

What problem does pow(proof of work) solves in blockchain?

Proof of Work: When a miner gets a ...READ MORE

answered Aug 6, 2018 in Blockchain by digger
• 26,740 points
1,163 views
+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,370 points
11,947 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
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
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
• 69,220 points
1,464 views
0 votes
1 answer
0 votes
1 answer

Calling function in truffle console error

Inside Truffle console ContractName.deployed().then(function(instance){app = instance}) app.adopt(23)//call method on ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,220 points
2,878 views
0 votes
1 answer

How to run a Javascript in truffle console?

There are two ways to do this. You ...READ MORE

answered Jan 24, 2019 in Blockchain by Omkar
• 69,220 points
2,506 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP