Truffle Console Variable Declaration

I am currently following this tutorial ( https://medium.com/zeppelin-blog/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05 ) when I try to sneak into over-the-air programming. Step 3 interacts with the deployed contract.

When i enter

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

      

I am getting "undefined" and cannot interact with the following commands. I definitely unwrapped the contract because

truffle(development)> ProofOfExistence1.deployed()

      

gets me the output and lists me all the functions inside the contract, etc. tried this with testrpc and geth testnet so i guess it has something to do with truffle?

+3


source to share


2 answers


The method .deployed()

returns a Promise

. Try:



truffle(development)> ProofOfExistence1.deployed().then(function(a) { poe = a; })
...
truffle(development)> poe.address

      

+3


source


To interact with deployed contracts, you must enter the truffle console:



truffle<development)> ProofOfExistence1.at("copy its address after the migration").function name();

      

+1


source







All Articles