我有一个 Truffle 示例应用程序,然后当我尝试在 truffle 控制台中与之交互时,我不明白为什么它没有部署或工作。
我激活 testrpc,然后输入:
> truffle console
> migrate --reset
> MetaCoin.new();
在那之后:
truffle(development)> MetaCoin.name
'TruffleContract'
truffle(development)> MetaCoin.country
undefined
truffle(development)> a1 = web3.eth.accounts[0];
'0x0a3d66a80b50875770fd264dd7c905f21395037f'
truffle(development)> MetaCoin.sendCoin(a1, 100);
TypeError: MetaCoin.sendCoin is not a function
at evalmachine.<anonymous>:1:10
at ContextifyScript.Script.runInContext (vm.js:59:29)
at Object.runInContext (vm.js:120:6)
at Console.interpret (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:199314:17)
at ReplManager.interpret (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:200019:18)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:440:10)
at emitOne (events.js:115:13)
at REPLServer.emit (events.js:210:7)
truffle(development)> MetaCoin.sendCoin(a1, 100);
它说 sendCoin 函数不是函数,所以我不确定如何与合约交互。我怎么能这么叫?