I'm trying to vote for candidate from particular account, like : app.vote(1,{ from: accounts[0] })
.
truffle console
truffle(development)> accounts
[
'0xA1d77380Cb26e30F336F7B45EdaFcE49543A4e53',
'0x48C9ae2AE4f031DDbfE605A56C4B59CAB7b54383',
'0x232fD7cb05Cd1b2849124466c4b14ff907b42DC5',
'0xAB6B92ED799DFEBA0d5bf65137Bf2c97682Beae5',
'0x3679b44250bBE27b287b0c07E6d8D16388bd7494',
'0xB353311c017ff9b3E20aa52f76F53D20fd6EAfD4',
'0x596a306BE6FE7bB18DFC9065A4f0a498cD74aF32',
'0xef277ADa2dc83aF974832D33056B649016c76Ea0',
'0x96D3ab6192566c74074FC11445B6b4e4640eF6Bd',
'0x1E9d006DF1e0F9FB013D23aB3702AddcF0119589'
]
truffle(development)> app.vote(1,{ from: accounts[0] })
Thrown:
evalmachine.<anonymous>:0
app.vote(1,{ from: accounts[0] })
^
ReferenceError: app is not defined
at evalmachine.<anonymous>:0:1
at sigintHandlersWrap (vm.js:272:15)
at Script.runInContext (vm.js:127:14)
at runScript (C:\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:222:1)
at Console.interpret (C:\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:237:1)
at ReplManager.interpret (C:\npm\node_modules\truffle\build\webpack:\packages\core\lib\repl.js:129:1)
at bound (domain.js:426:14)
at REPLServer.runBound [as eval] (domain.js:439:12)
at REPLServer.onLine (repl.js:726:10)
at REPLServer.emit (events.js:219:5)
Can anyone please tell me how to vote from perticular account.
Before interacting with your contract, you need to deploy it first (assuming you're inside of the Truffle project your contract is in):
truffle deploy
truffle console
truffle(development)> let app = await YourContract.deployed()
truffle(development)> let accounts = web3.eth.getAccounts()
truffle(development)> app.vote(1,{ from: accounts[0] })