2017-09-29 32 views
1

私はTruffleのサンプルアプリケーションを持っています。そしてそれをトリュフコンソールで操作しようとすると、なぜそれが展開されていないのかわかりません。truffle consoleの使い方

私は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関数は関数ではないと言うので、私はどのようにわかりません契約と対話するどうすればいいですか?

答えて

2

最初に、truffle migrateを使用して契約を展開します。

はその後トリュフコンソールから次のように契約と対話

MetaCoin.deployed().then(function(instance) {return instance.sendCoin(a1, 100);}).then(function(value) {console.log(value);}); 
関連する問題