I'm trying to test a contract with Truffle beta (because of the new web3 1.0.0 support).

When i try to create the contract object by using Contract = artifacts.require("Contract"); contract = Contract.at(Contract.address); and subsequently logging console.log(contract) it returns a pending promise.

I read the release notes and under 'breaking changes' it says that the .at function is now async. But when I try to prefix await to contract = await Contract.at(Contract.address); I get an error saying that the at function is in fact not async.

I noticed this error when I tried to call a function with contract.methods.myFunction(argument).call() and there was an error saying there is no 'methods' for undefined.

Has anyone experienced the same problem?

1 Answer 1


I solved it by replacing the contract = await Contract.at(Contract.address) with the Contract.deployed() function.

But I had to put the contract declaration inside each it block. With the older truffle version it used to work if it's declared once inside the contract block.

Many thanks to the people in the Gitter channel who helped me solve this problem!

  • 1
    1. "But I had to put the contract declaration inside each it" - you can declare var contract at a global scope, and then put the initialization of it (once) in a before clause. Sep 29, 2018 at 7:30
  • 2. "But when I try to prefix await... I get an error saying that the at function is in fact not async - it is in fact the scope in which you were using this await, which gave you the error. You can use await on both async and non-async function calls, but you can use it only inside async functions, which apparently you didn't (until you put it inside the it). Sep 29, 2018 at 7:30
  • 1
    3. I recommend replacing contract with a different variable name, because this symbol already exists in Truffle scope. Sep 29, 2018 at 7:31

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.