I will like to display the value of a variable in an existing smart contract in Truffle.

Here's my script:

module.exports = async function(callback) {
const project = artifacts.require("project");
let p = await project.at('0x4514bC8332c94AEE465e7c70B0d0497424A66D67');

So I run it hoping that it displays the value of state.

truffle exec test.js

But all I get is this, with no values displayed:

Using network 'development'.

1 Answer 1


Add await before p.methods.state.call().

You can also get rid of the await before project.at.

And AFAIK, you should use truffle test instead of truffle exec.

  • You are right. When I copy the same codes to my deployment script it actually works. Thank you!
    – Jackson Ng
    Mar 5, 2020 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.