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 in Blockchain by Shreya
60 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 by Omkar
• 67,660 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,170 points
693 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,550 points
66 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,170 points
1,013 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
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
• 67,660 points
460 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 in Blockchain by Omkar
• 67,660 points
80 views