错误-当在松露智能合约上部署时,等待仅在异步功能中有效

问题描述 投票:0回答:1

跟随tutorial on the truffle website。是否按原样进行了每个步骤和设置。我的truffle compiletruffle migrate正常工作。但是,当我尝试在松露控制台中执行let instance = await MetaCoin.deployed()时,出现此错误-

evalmachine.<anonymous>:1
let instance = await MetaCoin.deployed()
               ^^^^^

Uncaught SyntaxError: await is only valid in async function
ethereum solidity smartcontracts truffle
1个回答
0
投票

看上去MetaCoin似乎未正确定义确保您没有在迁移脚本中缺少以下步骤之一例如:]]

 const MetaCoin = artifacts.require("YourContractFilame")
 await deployer.deploy(MetaCoin)
 const deployedMetaCoinContract = await MetaCoin.deployed()
© www.soinside.com 2019 - 2024. All rights reserved.