I have updated my truffle version to the latest v5.0.3
. By running truffle version
, I can get the following version statements.
Truffle v5.0.3 (core: 5.0.3)
Solidity v0.5.0 (solc-js)
Node v10.8.0
However, this update stops me from executing some tutorials that were supposed to work. Especially, the ZOS tutorial at https://docs.zeppelinos.org/docs/upgrading.html, when running commands myContract.x().toString()
in Truffle Console. Instead of showing a numerical result, the console kept showing undefined
. The same problem happened for the case of running myContract.s()
.
I am not sure whether the problem comes from a different use of cli command sets across versions. It took me hours to fix it. Therefore, if you encountered similar problems, I wish it can save you time.
myContract.x()
should return a promise, which when resolved, yields aBigNumber
instance (or on Truffle 5, possibly aBN
instance, due to the upgrade of web3 version). I'm not sure why this works for you on Truffle 4, but you should generally resolve the promise before callingtoString()
. You can do this, for example, with(await myContract.x()).toString()
.undefined
constantly.(await myContract.x()).toString()
, which returnedTypeError: myContract.x is not a function
. And(await myContract.x)
returnedundefined
. Interesting haha.myContract.methods.x
. Truffle 5.x relies on web3 1.x, which dictates this syntax.