strange-labs-uk / ethereum-raffle

Simple raffle style lottery DApp
7 stars 2 forks source link

Work out how to interact with contract from truffle #2

Closed binocarlos closed 6 years ago

binocarlos commented 6 years ago

From the Readme:

In the truffle(develop)> console:

deploy --reset
test

Now you can interact with the lottery contract, you can create a pointer to it as follows:

var lot = Lottery.at(Lottery.address)

However, I have not figure out how to interact with it beyond this yet so if anyone can figure it out, please share your wisdom.

ccdle12 commented 6 years ago

I managed to interact with the deployed contract by:

Can push to a new branch for people to play around with it?

screen shot 2018-01-17 at 13 44 00

ccdle12 commented 6 years ago

Also you can continue to interact with the contract from the truffle develop console:

Just call functions that are publicly available:

Although haven't looked deeply into how to buy the token from the truffle develop console

screen shot 2018-01-17 at 14 50 28
brtkwr commented 6 years ago

Nice! I also managed to buy LTK lottery tokens in exchange for ether and see how much I had accumulated so far:

lot = Lottery.deployed()
lot.then(function(instance){return instance.send(10);})
lot.then(instance=>instance.weiRaised())

Check your LTK balance:

ltk = lot.token().then(address=>LotteryToken.at(address))
ltk.then(instance=>instance.balanceOf(web3.eth.coinbase))

I have updated the README.md accordingly. Next stop, generate random numbers! I will close this issue as it is no longer relevant :) Thanks guys!