Programming Project - Phase 2

everything is fine as needed to be created still getting this error
Error: ENOENT: no such file or directory, open ‘.secret’

can anyone please help

Are you in the directory where your .secret file for the HDwallet lies?
Maybe .secret is not possible on Windows machines…

Hi. I’m not able to run my dapp on ropsten testnet. I’ve updated the code to use the oracle, but when I tried it on the testnet the buttons of the dapp don’t work.
I don’t see any errors, and I’ve added some alert() in the button functions to see if they were executed. All alert() I’ve added show up, either in the beginning or end of the button functions. what appears that doesn’t work is all web3 code.
I’ve tried to run the previous code without oracle changes and it also doesn’t work on ropsten testnet. I’ve also tried with Ganache and it works fine.

I’ve committed my latest code to github: https://github.com/LSilveira/FlipCoin/blob/main/main.js

@Luis_Silveira
You are not sending the tx correctly using web3.
Check this comment I left to another student :slight_smile:

Documentation: https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html

The compiler is telling you that you don’t have a .secret file in your the root dir of your project.
I replied you in another post you’ve made, suggest to double check Filip’s lessons as these things are well explained and he guides you step by step in the implmentation.

Happy learning,
Dani

Is it just me or are there issues going on with the Ropsten Testnet currently? Nothing gets deployed and no minable transactions are being mined.

EDIT: I tried to self-destruct my contract and it took more than 30 mins for it to get mined and deploying a new one is still running and it’s taking super long to re-deploy my contract.

I faced the same issue couple of days ago. Sometime Ropsten is slow/ does not work correctly.
It is normal as we are talking about a testnet.

These downtimes can be useful to learn new things, you can indeed use another testnet instead of Ropsten.

Anyone have a Ropsten faucet that is working right now? I am trying to put test ETH into my Metamask Account 1. the Metamask Get ETH gives…{“error”:"[ethjs-query] while formatting outputs from RPC… I googled and tried few more but none of them seem to work :frowning:
I am trying to fix this error which I think I am getting because my eth account has 0 balance.

Error: Error: Error: *** Deployment Failed ***

“Migrations” – insufficient funds for gas * price + value.

at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:96:1)
at process._tickCallback (internal/process/next_tick.js:68:7)

Truffle v5.0.42 (core: 5.0.42)
Node v10.3.0

****** Tried a faucet from this discussion and it worked! I have 0.5 ETH

1 Like

try this one: https://faucet.dimensions.network/

1 Like

Here is my submission for Phase 2: https://github.com/cpontrelli/eth-coin-flip

Below is are pictures of a winning flip and transferring the winnings

Please let me know if you have any feedback, thanks in advance!

Hey @Charlie_Pontrelli

I took a look at your code.
Can you please clarify this statement:
require(msg.value > 0 && msg.value <= (freeBalance / 50));
Why is it / 50?

Also try to use the param _proof provided by the oracle.

function __callback(bytes32 _queryId, string memory _result, bytes memory _proof)

Well done overall :slight_smile:

1 Like

I was able to migrate the contract in the ropsten network.

when I try to interact with the contract I get this error from metamask:

error in the tx exception created in the contract

is it a metamask issue? (i tried to reset the account as you told me but it gives the same error)

thanks

Hi @CrazyCanadia,

sorry for the late answer. I didnt check the forum for a while… Thanks for your interest in the idea!

I am also not an expert and not 100% sure about the incentives for manipulation. My idea was that, by using a future blockhash to decide the winning you can at least avoid the abuse by smart contracts (if you use anything from within the present or past blocks a smart contract could easily undo the bet in case it doesnt win). However, miners can in principle still manipulate. But in order to get a “safe” bet, they would have to premine the blocks and would lose a lot of block rewards. Maybe one could increase the security to this end by using not the hash of the next, but an even later block to decide the bet. They might also get a slight edge by committing to the bet, but not publish the “deciding block” if it would loose their bet. I guess that one would need substantial hashing power for these exploits to be feasible. However, if the involved amounts are large it might still be possible. Its certainly not 100% safe.

As you wrote, it would be interesting to get an experts view on the idea.

1 Like

Hey @dan-i , thanks for the feedback. I will take a look at using the _proof.

I divided by 50 to prevent a user from liquidating the contract with 1 bet. Otherwise I figure someone can just keep betting the max amount until they win once and take everything.

@dan-i I added a check using the _proof param according to your suggestion.

https://github.com/cpontrelli/eth-coin-flip

1 Like

That is most likely an issue in your contract. A require statement which is reverting.

I divided by 50 to prevent a user from liquidating the contract with 1 bet. Otherwise I figure someone can just keep betting the max amount until they win once and take everything.

Shouldn’t this be /2?

Contract balance = 1 ether,
user max bet 0.5 eth

Let me know if I misunderstood :slight_smile:

More than 2 months since I deployed original contract to Ropsten network, I finally managed to adapt my code to work with Oracle. To be fair I did not work on my code for two months but more like two weeks with two really effective days…rest of the time I was busy with my regular work and procrastination. :stuck_out_tongue_winking_eye:
Two days ago I even received Ivan’s email asking me where did I go? :sweat_smile:
Anyway I’m back now and I’m ready to continue where I’ve stopped.

MkDapp in action:


Github repository: https://github.com/MrGanD/MKDapp/tree/PHASE2

Big thanks to Mario whose solidity code I’ve used as a foundation for my Dapp.

1 Like

Yeah dividing by 2 would definitely be sufficient for preventing the contract from getting completely liquidated, but in my opinion is still a bit risky.

For example if a user makes a bet of 0.5 eth and wins then makes another bet of 0.25 eth and wins the contract has already had 75% of it’s value liquidated. Granted, the contract could never be completely liquidated, but 75% in two bets seems like a bit too much.

I decided on 50 because even with insanely good luck it would be nearly impossible to liquidate large portions of the contract.


Hi @filip

  1. The above file does not exist. I can see this file instead with the same name. Which file to use?

  2. In my metamask, I changed to ropsten network and thrice requested 1 ETH from metamask faucet. However I have not received any ether. How to solve this?