dappuniversity / eth-todo-list

Blockchain Todo App Tutorial Powered by Ethereum Smart Contracts
556 stars 550 forks source link

taskCount() is not a function error #23

Closed 1Hanif1 closed 2 years ago

1Hanif1 commented 2 years ago
truffle(development)> tl.taskCount()
evalmachine.<anonymous>:0
tl.taskCount()
   ^

Uncaught TypeError: tl.taskCount is not a function
    at evalmachine.<anonymous>
    at Script.runInContext (node:vm:139:12)
    at runScript (C:\Users\hanif\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:366:1)
    at Console.interpret (C:\Users\hanif\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:381:1)
    at bound (node:domain:421:15)
    at REPLServer.runBound [as eval] (node:domain:432:12)
    at REPLServer.onLine (node:repl:889:10)
    at REPLServer.emit (node:events:390:28)
    at REPLServer.emit (node:domain:475:12)
    at REPLServer.Interface._onLine (node:readline:487:10)
truffle(development)> tl.taskCount()
evalmachine.<anonymous>:0
tl.taskCount()
   ^

Uncaught TypeError: tl.taskCount is not a function
    at evalmachine.<anonymous>
    at Script.runInContext (node:vm:139:12)
    at runScript (C:\Users\hanif\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:366:1)
    at Console.interpret (C:\Users\hanif\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:381:1)
    at bound (node:domain:421:15)
    at REPLServer.runBound [as eval] (node:domain:432:12)
    at REPLServer.onLine (node:repl:889:10)
    at REPLServer.emit (node:events:390:28)
    at REPLServer.emit (node:domain:475:12)
    at REPLServer.Interface._onLine (node:readline:487:10)

I am able to access the tasks mapping but this is throwing an error and i can't figure out why

1Hanif1 commented 2 years ago

"Member "taskCount" not found or not visible after argument-dependent lookup in contract TodoList" again why is it showing this?

1Hanif1 commented 2 years ago

Turns out I am stupid smh uint256 public taskCount = 0; forgot that the function to view a field value is provided by solidity ONLY if the field is public 🤦‍♂️