Well done Guy your contract works perfectly
Everything is fix , good job !
gabba Filip and Ivan,
Really. thank you for Everything.
Best course I experienced. Professionally (and personally …). never enjoyed so much learning a new field (coding…from scratch).
Any ideas for how to synergy it with my experience as financial advisor will be more than welcome
Thanks again
Guy
Here is my code for Coinflip assignment: https://github.com/Crypt0Dragon/IvanOnTech/tree/master/ethereum-201
here is the video of my coin flip dapp:
Hi,
this is the first working version of my project and my hand in. Thanks for checking it out. I am not sure if i find time to fine-tune it. Maybe though, because i am looking forward to the smart contract security course.
Anyone can bet anyone. The house gets a 2% cut if the coin is flipped. You can cancel your bet before anyone joins it. It will show your bet in the list on the bottom, as soon as the GameCreated event is emitted. You can not join your own bet with the same address that it was created with (This limitation only concerns the web interface - using the contract directly you can join your own bets - button is just hidden). So you need to change your account in metamask to see the “Bet 0.5 Ehter” button in place of the “Cancel” button.
I use angular for my frontend. (learned everything from Tour-of-Heroes) The little avatar images are from robohash.org and reflect the wallet address.
TODO:
- Unit Tests !!!
- filter for bets (eg. Created by me, Won, Lost, …)
github - CoinFlipDApp
github - CoinFlipContract


I am just starting my reading assignment on Developer Mindset for the Security course. The first couple lessons reminded me of my inner perfectionist. I will definitely keep working on this project. So much to improve. I am pumped. Learning is fun. Thanks @filip.
Thx @Guy
Do not hesitate to give a review about the academy here
https://uk.trustpilot.com/review/academy.ivanontech.com
It will help us growing
I think the Defi space is huge have look at the Defi course , there is many things you can experiment with
Hi @abuga
I don’t know if you just wanted to experiment with provable api (in this case it’s fine) or use this project in your Portfolio to find a job in Crypto (in this case it’s a bit minimalist no offense ) it’s a final project so i’m sure you can add many features.
Your game mechanism works fine , your request to the api is resolved and you are transferring the eth back if the user win but you can improve many things, here are my recommendations.
- There is no way to fund your contract
- You are not checking if the balance of the contract is big enough before taking the bet
- No test suite
- The transfer function cost you gas because it’s called by your callback it’s better to implement a withdraw function for the user
- You are not checking it the msg.value is greater than 0, a call to the provable api will cost you gas so i can empty your contract by just calling flip with 0 ETH.
- Implementing an event handler will be nice to catch the result emitted and you could display it on the web page.
- The owner of the contract is not able to get back the funds.
You can look at other students’ projects if you want to get inspired.
Again i think this is a good project to add to a portfolio if you want to get a job in crypto, so show everything you have learn during the course.
Well done @CryptoDragon don’t forget to deduce the price of each call from the provable api otherwise your final balance will not be correct.
As you can see now the balance is 0.34 but your function is displaying 0.40.
Also do not allow a transaction with an empty msg.value it should be minimum the price of the provable api call.
Unit testing missing
Hi @mawize
Really interesting way to solve this project
I like the way you use this “state” to control your program flow.
I didn’t run your graphical interface as you didn’t linked the json files, i m not using angular so it’s a lot of stuff to install to test 1 projects. But i had test your smart contract in remix and it’s really cool.
I had to wrap my head around it at first eheh .
Just few questions
Why your functions claim/cancel/collect are payable ?
I went to the state 4 but how to restart a new game, do we have to create a new Coinflip contract for each game ? Otherwise you could just selfdestruct your contract when you are calling “collect” it ll be cheaper to get back your eth.
Do you have a live version on ropsten i ll love to try it live. Look at heroku you can host it for free
Hi @gabba,
thank you for your feedback.
I went to the state 4 but how to restart a new game, do we have to create a new Coinflip contract for each game ? Otherwise you could just selfdestruct your contract when you are calling “collect” it ll be cheaper to get back your eth.
Yes, exactly. The Casino contract deploys a CoinFlip contract for each bet.
After reading some more about the payable
modifier and the selfdestruct()
i made the suggested changes to the CoinFlip contract. I also added a Dockerfile
and a docker-compose.yml
to the CoinFlipDApp repository so you can just run it with docker and not have to worry about installing all the software. Now you just need to docker-compose up
and its ready to use at http://127.0.0.1:4200/
Nevertheless i will put it up on my server so anyone can try. Nice goal for tomorrow
Do you have a live version on ropsten i ll love to try it live. Look at heroku you can host it for free
Still not 100% working. I’ll test some more later.
Seems that the contract is not getting called back by the oracle.
I am currently getting this error
ValueError: {‘code’: -32000, ‘message’: ‘insufficient funds for gas * price + value’}
when trying to deploy my test contract. Not able to find much help online for this error.
Can anyone point me to some resources that can help me work through this error?
Hi @Illidan7,
maybe this helps you:
If it doesn’t maybe post your deployment code for the test contract.
Cool i ll try it this week
I had issues with ganache Gui not sending back events , did you try with ganache-cli ?
No, i am not using ganache-cli. I think it has to be the code. Please kindly checkout my code of usingRandomProvable.sol. Maybe you have an idea why its not working.
Thanks for your help.
Oh my bad i though you were talking about events …
Can you share your transaction id ?
We had many issue with the provable api being offline …
Oraclize Support @oraclize-support 21:03
Hi @marcelomorgado - sorry yes, there was a small outage, any pending queries you may have had in flight are being reprocessed as we type.
0x49a2c4bfb68d7a46434d96c2ccba83c6dc42305720332a13fc00068df709d2a2
I added links to etherscan on my webfront. So you can easily follow your bet/transaction.
Try it out!
Hey @mawize
I tried your web interface, it’s nice but i can only create a bet from their, how can i join one ?
Your code for the provable api seems correct can you emit an event in both functions
__callback
and getRandomNumber
Did you check my link for the provable api gist ? it seems the network is down
Evgeni Pirianov @BatiGencho 00:59
@oraclize-support When are you finally going to fix ropsten ?
It will show your bet in the list on the bottom, as soon as the GameCreated event is emitted. You can not join your own bet with the same address that it was created with (This limitation only concerns the web interface - using the contract directly you can join your own bets - button is just hidden). So you need to change your account in metamask to see the “Bet 0.5 Ehter” button in place of the “Cancel” button.
Thank you so much for helping. I checked your link and feel like it might have something to do with it.