Truffle: Truffle Console not working

Created on 30 Sep 2017  路  2Comments  路  Source: trufflesuite/truffle

  • [ ] I've asked for help in the Truffle Gitter before filing this issue.

I did and the person told me not to use truffle console.


Issue

I'm trying to run the MetaCoin example in the console.

Steps to Reproduce

I ran the following:

$ truffle migrate
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x655e6257e6c7c0cc9591196cbb0911e714efeb4896401dcb8b639c4928d82511
  Migrations: 0x4a49adb28c75892c95afb4dfec9a8015885495cf
Saving successful migration to network...
  ... 0x5aab19e268906579904fb8e6a2d0d812984f4bbad67957cbbf9d2748f0ffb3cd
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying ConvertLib...
  ... 0x4df7d8843210070723782d6a5e03d210e901a84b8b53ff0258eea63ab73291ac
  ConvertLib: 0xa5bd89df0a8d069899b7ef07d440706bf560c7aa
  Linking ConvertLib to MetaCoin
  Deploying MetaCoin...
  ... 0x92008b98116d863f425c18d2b528fd0a426b18e8ea9585d86c2c400f1a956fcd
  MetaCoin: 0x17c4ac87f01d993c2789cd07cd97a822c95bb9a1
Saving successful migration to network...
  ... 0xaf18407fee5da8f497519d4ebb55bfe39c4d808862cc8b0a83141ac8d80b2170
Saving artifacts...

Then, I do:

    $ truffle console
truffle(development)>

After that:

truffle(development)> a1 = web3.eth.accounts[1]
'0xd27c63fad1a69420205668cb4c06269d535cc52b'
truffle(development)> MetaCoin.sendCoin(a1, 10)
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)>

Expected Behavior

I was expecting that I would be able to send the meta coins to the account.

Actual Results

There is an error.

Environment

  • Operating System: MacOS
  • Truffle version:Truffle v4.0.0-beta.0 (core: 4.0.0-beta.0)
  • Ethereum client: Truffle console/ web3
  • node version: v8.6.0
  • npm version: 5.4.2

Solidity v0.4.15 (solc-js)

Most helpful comment

I believe the correct syntax for calling the sendCoin function is

MetaCoin.deployed().then(function(MetaCoinInstance){
    MetaCoinInstance.sendCoin(a1, 10);
});

All 2 comments

I believe the correct syntax for calling the sendCoin function is

MetaCoin.deployed().then(function(MetaCoinInstance){
    MetaCoinInstance.sendCoin(a1, 10);
});

Thanks for providing the syntax example @asifmallik, and thanks @designium for reminding us that certain use cases are unclear :D

Was this page helpful?
0 / 5 - 0 ratings