Programming Project - Phase 1

First lets fix the migration.

const Coinflip1 = artifacts.require("Coinflip1");

module.exports = async function(deployer, network, accounts ) {
  await deployer.deploy(Coinflip1);
  const instance = await Coinflip1.deployed();
  await instance.addBalance({from: accounts[0], value: web3.utils.toWei("5", "ether")});

  console.log(`The contract balance is ${await instance.balance()}`);
};

Screenshot 2020-12-29 at 18.48.46

Now I can play.

1 Like

Here is my solution with simple/minimal design.
GitHub: https://github.com/ricoto/bet-game

Design looks really basic.

1 Like

Hi @dan-i

In Ganache, my accounts[0] is almost out of ether. How do I get more ether in accounts[0]?

I tried the following

npm install -g ganache-cli
ganache-cli --defaultBalanceEther 10000

1 Like

Docs suggest ganache-cli -e 1000
Screenshot 2020-12-30 at 09.27.49

If you use the gui just check the settings

Hi @dan-i

When I entered the new mnemonic in Ganache I can see 0 ether. How to solve this?

image

Hey @oneworldcoder

The command I gave you runs ganache-cli (you run a blockchain emulator directly in your terminal).

If you want to use the GUI version of Ganache, you can set the default ETH amount by opening settings -> accounts & keys
image

Let me know if that works,
Dani

Hi @dan-i

I would prefer to use the GUI version. settings -> accounts & keys does not work. How to solve this?

It’s not the prettiest thing in the world, but it works!

https://www.dropbox.com/s/opslxfoip6f0w28/Coin%20Flipp%20dApp.mp4?dl=0

I definitely learned a lot troubleshooting this project. Can’t wait for Phase 2!

2 Likes

Hi @oneworldcoder

Can you specify settings -> accounts & keys does not work.?
It is a built in function in Ganache and, unless there is a bug in your version, it should work.

Open Ganache, create a new project and set the amount of eth as in my previous screenshot.

Hi @dan-i

When I go to accounts & keys, enter my mnemonic set default balance to 1000 and click on restart I can see 0 ether as balance. Should I re-install ganache?

1 Like

Hey @oneworldcoder, hope you are good.

There is no need to reinstall ganache, what you could also try if none of the suggestion that my colleague @dan-i has been mentioned to you.

At the start of ganache, you can have multiple workspaces, just create a new one and will generate a entire new blockchain, private keys and wallets for you to start fresh again, also you could delete the old workspace if you are having too many issues with in.

Carlos Z

2 Likes

Hi @thecil

It works now. Thank you.

@dan-i @filip

complete phase 1

1 Like

My project https://github.com/oneworldcoder/Coinflip-Part1

1 Like

Deposit:


Bet:


1 Like

It was a nice assigment! Did it with React…




1 Like

Well done @Aiisnotbad it looks great!

1 Like

Here is my work so far. First time programing with JS, HTML and still pretty new to Solidity. I based the Dapp in the examples from past lectures. That is why it is so simple. Basically you choose how much ETH you want to bet, then hit the “Toss the Coin” button and wait for the result.

Here is the link to a short video: https://drive.google.com/file/d/18lMSPyUzSAOrqLw67-U0qHey6Vi17Ldt/view?usp=sharing

Thanks :slight_smile:

1 Like

Well done @MarkBravo :clap: :clap:

Ready for phase two now

1 Like

Here is mine - a short gambling photo story.
The bet:

The result:

Refreshing stats:

3 Likes