This command generate boiler plate file and directory for truffle project
To migrate the contract to blockchain
TO migrate the contract and deployed on blockchain
Make sure the ganache is open which is our local blockchain
To go into truffle console mode
Election.deployed().then(function(instance){app = instance;})
Meme.deployed().then(function(instance){app = instance;})
'Candidate 1'
Blockchain is immutable (unchangeable) so we have to --reset everythin
It is like dropping all the table in database and starting from beginning
call function get candidate at 1
app.candidate(1).then( function(c){candidate =c;})
undefined
truffle(development)> candidate
Result {
'0': <BN: 1>,
'1': 'Candidate 1',
'2': <BN: 0>,
id: <BN: 1>,
name: 'Candidate 1',
voteCount: <BN: 0> }
truffle(development)> candidate[0]
<BN: 1>
truffle(development)> candidate[1]
'Candidate 1'
truffle(development)> candidate[2]
<BN: 0>
truffle(development)> candidate[2].toNumber()
0
truffle(development)>
See accounts in w3 command
web3.eth.getAccounts()
npm run dev
This command run lite serve and open browser
web3.eth.getAccounts().then(function(accounts){acc=accounts;})acc
web3.eth.getAccounts().then(function(allAcc){acc=allAcc;}).then(function(acc){selected=acc[0];})
app.candidate(); ----------------- 'Candidate 1' app.addRequest('rpatel@csus.edu','smit@gmail.com')
app.addRequest('smit@gmail.com','vivek@gmail.com')
app.addRequest('vivek@gmail.com','smit@gmail.com')
app.addRequest('rpatel@csus.edu','vivek@gmail.com')
app.addRequest('vivek@gmail.com','rpatel@csus.edu')