Programming Project - Phase 2

Nice, thanks I’ll take that course after this!

1 Like

Hey there, im getting some similar errors.

Hi @Rob_McCourt

These are normal warnings not errors.
You can use your package normally.

Ah see. Yeah the package is there thats the main thing i suppose.

I shall move on to the next step.

Will let you know if anything crops up D.

Thanks

1 Like

hi @filip
I am getting this error
Error: Error: Error: *** Deployment Failed ***

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

trying to get a eth from faucet, but not seeing any update in account balance, I can see the transactions logged on faucet web site, any suggestions?

@filip @dan-i I am getting this error while deploying the contract, sorry If I am double posting my question
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)

Now I tried to get some balance on faucet.metamask.io however my account balance is not updating. I am attaching the

screen shot here

So my question is how long does it take to get balance? do you think there is any step I am missing here?
so basically

  1. Imported a contract with private key of one of the ganache account.
  2. change metamask network to roosten.
  3. Followed the steps mentioned in setup lecture.
  4. requested balance from faucet.metamast.io

Hey @kHarsh

The error you are facing is telling you that the wallet used to deploy the contract does not have enough funds to complete the migration.
Keep in mind that, by default, truffle migrates using account[0], which is what you see as Account 1 in metamask.
You probably have a file .secret in the root directory of your project with a mnemonic phrase in it, that is the wallet that is going to pay for the deployment.
Make sure that Account 1 in Metamask has enough funds.

In your screenshot you have selected Account 3, switch to Account 1 copy the address and use a faucet to get testnet ETH (suggest: https://faucet.dimensions.network ).

Then migrate again.

Cheers,
Dani

Fantastic! Finally it now works :slight_smile:

as last thing for my project I’d like to hide the buttons concerning the owner (for example the withdraw or deposit button that only the owner is suppose to use should appear only when its address i connected to the dapp)

I used the following to hide the buttons

<div id="hide" style="display:none;">
</div>

in the main.js file i should set the condition:

function showOwner() {
if(msg.sender=accounts[0]){
document.getElementById("hide").style.display="block";
}
}

it is not working so I’m not sure how to set the condition : if(msg.sender=accounts[0])

:slight_smile:

Hi @enrico

In coding you can compare two elements by using == or ===.
One single equal is wrong as you use it to assign a value.

Fix that and try again.

Cheers,
Dani

Hey why does filip uses a constructor here, insteads of just declaring the update function as public ?

Hey @ArgenFrank

The constructor method exists in all programming languages and is a method that runs as soon as the program (or in this case the contract) is deployed.
It runs only once and cannot be called anymore.
What Filip is doing there is just call the function update() when the contract is deployed.
There is no relation between the visibility of the two functions (public).

Cheers,
Dani

1 Like

here is my solution https://github.com/Niore/coinflip-oracle

1 Like

Thank you dani for clearing it up. So why is it that i need to call update as soon as the contract is deployed? Wouldnt it only benefit the first player as he wouldnt have to wait for the oracle to respond ??

Hi @ArgenFrank

Filip coded the update function in the constructor just as example, there is no need to call update as soon as the contract is deployed :slight_smile:

Hello . Sorry but I have problems with Ifura. i dont know what to do.
I checked a very simple contract and it does not work.
I received always this error.
I changed to visual studio to check if there is something different here



In remix works

Hey @camarosan

I also got that Infura error few times, try to create another Infura account and use a different key.

Keep me posted,
Dani

Does someone know why we should pay for oracles if we have the capability to do our own http request to external apis even from our frontend, what are the benefits of the complexity of implement an oracle and pay for a service that your own backend is able to carry on?

@Javier_Vazquez_Ferna a smart contract has to function without the need of any other code but solidity.
By querying an API, your contract will be dependent by your js backend.

Sure you can still do that, but then all the users of your contract have to inherently trust you and your data.

Hello @dan-i
Today I finally solved the problem, but I will resume everything I did. I was really frustrated on this one

  • I changed my contract for one very easy to implement. On remix all my projects works
  • I created another account in metamask with new seed and new addresses
  • I changed Atom by Visual Studio(thanks to the course from react I know how to use it)
  • I have some virtual network cards for vmware and I disable all of them
  • I checked my latency in my LAN and WAN
  • I disabled my firewall and antivirus
  • I used some networking programs to check my traffic (wireshark etc)
  • I reinstalled almost everything node.js, powerShell etc. I finally installed the latest version of node.js
  • I disconnected wifi and use a direct LAN cable for internet(with rj45)
  • I created another account on infura.io and also created other projects on the same account

This is the solution. I always thought on this but who knows maybe my public ips are blacklisted on Infura. I used a vpn.

E:\Importante\Programas creados imagenes iso etc\Programas blockchain\proyectos\SimpleCoin>truffle init

Starting init...
================


> Copying project files to E:\Importante\Programas creados imagenes iso etc\Programas blockchain\proyectos\SimpleCoin

Init successful, sweet!


E:\Importante\Programas creados imagenes iso etc\Programas blockchain\proyectos\SimpleCoin>truffle migrate --network ropsten

Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SimpleCoin.sol
> Artifacts written to E:\Importante\Programas creados imagenes iso etc\Programas blockchain\proyectos\SimpleCoin\build\contracts
> Compiled successfully using:
   - solc: 0.5.12+commit.7709ece9.Emscripten.clang



Starting migrations...
======================
> Network name:    'ropsten'
> Network id:      3
> Block gas limit: 8000029 (0x7a121d)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x301b0ca2526c71f7fab1e51197bca975b0d48cc12a2ac2da4415e77efe7addcf
   > Blocks: 1            Seconds: 24
   > contract address:    0xb97041DC20FEd748E6D3E06963f91a82A153d657
   > block number:        9644503
   > block timestamp:     1613080243
   > account:             0x99Ef73c7a34f12E6977b05087fBA0742D88bd87D
   > balance:             12.541779885831173969
   > gas used:            191943 (0x2edc7)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00383886 ETH

   Pausing for 2 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 9644504)
   > confirmation number: 2 (block: 9644505)

   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00383886 ETH


2_SimpleCoindeploy.js
=====================

   Deploying 'SimpleCoin'
   ----------------------
   > transaction hash:    0x583af1cb779a4ca9af4d57326d3dcbed13f9a4d1d52d49d7e1d2f5c2d0a46d26
   > Blocks: 0            Seconds: 4
   > contract address:    0xDbb9e53785e88FbCceD4E1D2B079f0e64128bC9c
   > block number:        9644507
   > block timestamp:     1613080333
   > account:             0x99Ef73c7a34f12E6977b05087fBA0742D88bd87D
   > balance:             12.535580185831173969
   > gas used:            267647 (0x4157f)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00535294 ETH

   Pausing for 2 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 9644508)
   > confirmation number: 2 (block: 9644509)

   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00535294 ETH


Summary
=======
> Total deployments:   2
> Final cost:          0.0091918 ETH



E:\Importante\Programas creados imagenes iso etc\Programas blockchain\proyectos\SimpleCoin>

without vpn I always have the same error

I will finalize my Bitcoin courses and then I will study the new version of Ethereum 101 course, after that I will continue my project and check again with the Ips of my service provider again
See you later

Hey guys,

So I’m pretty much done with the updated contract. My only concerns are how can I ensure that the required amount of gas is taken from the update() function and that, that amount doesn’t affect the contracts balance.

Please also point out any vulnerabilities I might have missed.

Thanks a bunch!

CoinFlip-code