Skip to content

Latest commit

 

History

History
99 lines (68 loc) · 2.07 KB

File metadata and controls

99 lines (68 loc) · 2.07 KB

Project Detail

truffle unbox pet-shop


This command generate boiler plate file and directory for truffle project

truffle migrate


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

truffle console


To go into truffle console mode

call function to check variable inside the contracts


Election.deployed().then(function(instance){app = instance;})

Meme.deployed().then(function(instance){app = instance;})

app.candidate();

'Candidate 1'


truffle migrate --reset

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()

lite-server


npm run dev
This command run lite serve and open browser

Command to get all accounts


web3.eth.getAccounts().then(function(accounts){acc=accounts;})acc

web3.eth.getAccounts().then(function(allAcc){acc=allAcc;}).then(function(acc){selected=acc[0];})


Print the variable in truffle console

app.candidate(); ----------------- 'Candidate 1'

Friend List

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')