Was following the tutorial on the truffle website . Did each step and setup as is. My truffle compile
and truffle migrate
work as intended. But when I try to do let instance = await MetaCoin.deployed()
in truffle console, I get this error -
evalmachine.<anonymous>:1
let instance = await MetaCoin.deployed()
^^^^^
Uncaught SyntaxError: await is only valid in async function
Looks like MetaCoin
is not correctly defined defined Make sure you are not missing one of these steps on you migration script eg:
const MetaCoin = artifacts.require("YourContractFilame")
await deployer.deploy(MetaCoin)
const deployedMetaCoinContract = await MetaCoin.deployed()
Try to put it in async function and then use.then(), .catch() to see if your contract is deployed...
For anyone that came across this error it looks like the async function was left as a regular function
module.exports = >async< function(deployer, network, accounts)
So since the async was left out when await was used it couldn't pair with the correct async function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.