Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Truffle console variable declaration

I'm currently following this tutorial (https://medium.com/zeppelin-blog/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05) as I try to get into ethereum programming. Step 3 is interacting with the deployed contract.

When I enter

truffle(default)> var poe = ProofOfExistence1.deployed()

I get "undefined" as a result and cannot interact with the following commands as well. I definitely deployed the contract, because

truffle(development)> ProofOfExistence1.deployed()

gets me output and lists me all functions inside the contract etc. tried it with testrpc and geth testnet so I guess it's got something to do with truffle?

like image 543
Daniel Gretzke Avatar asked May 08 '17 21:05

Daniel Gretzke


People also ask

How do you paste in truffle console?

Use right click and paste. It works for me.

What is truffle console?

Truffle Console: A basic interactive console connecting to any Ethereum client. Truffle Develop: An interactive console that also spawns a development blockchain.


1 Answers

The .deployed() method returns a Promise. Try:

truffle(development)> ProofOfExistence1.deployed().then(function(a) { poe = a; })
...
truffle(development)> poe.address
like image 196
acdcjunior Avatar answered Sep 28 '22 00:09

acdcjunior