Dapp Introduction

Hey @dan-i
I am receiving the following error after sending 0.5 ETH transaction through my created Dapp… :point_down:

inpage.js:1 MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"the tx doesn't have the correct nonce. account has nonce of: 14 tx has nonce of: 20","code":-32000,"data":{"stack":"Error: \n    at validateNonce (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/statemanager.js:964:11)\n    at blockchain.getQueuedNonce (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/statemanager.js:973:7)\n    at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/blockchain_double.js:436:5\n    at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:77:5\n    at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:461:14\n    at Object.return (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:485:9)\n    at processNode (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:285:30)\n    at processNode (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:521:5)\n    at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:516:13\n    at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:180:7\n    at _combinedTickCallback (internal/process/next_tick.js:131:7)\n    at process._tickCallback (internal/process/next_tick.js:180:9)","name":"TXRejectedError"}}}}' {code: -32603, message: "Error: [ethjs-query] while formatting outputs from…ext_tick.js:180:9)","name":"TXRejectedError"}}}}'"}
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:1
_runReturnHandlers @ inpage.js:1
_processRequest @ inpage.js:1
async function (async)
_processRequest @ inpage.js:1
_handle @ inpage.js:1
handle @ inpage.js:1
_rpcRequest @ inpage.js:1
sendAsync @ inpage.js:1
s.send @ web3.min.js:1
n @ web3.min.js:1
(anonymous) @ web3.min.js:1
u @ web3.min.js:1
(anonymous) @ web3.min.js:1
(anonymous) @ inpage.js:1
Promise.finally (async)
_handle @ inpage.js:1
handle @ inpage.js:1
_rpcRequest @ inpage.js:1
sendAsync @ inpage.js:1
s.send @ web3.min.js:1
n @ web3.min.js:1
t @ web3.min.js:1
t @ web3.min.js:1
o._executeMethod @ web3.min.js:1
(anonymous) @ main.js:24
dispatch @ jquery-3.4.1.min.js:2
v.handle @ jquery-3.4.1.min.js:2
web3.min.js:1 Uncaught (in promise) {code: -32603, message: "Error: [ethjs-query] while formatting outputs from…ext_tick.js:180:9)","name":"TXRejectedError"}}}}'"}
(anonymous) @ web3.min.js:1
setTimeout (async)
_fireError @ web3.min.js:1
u @ web3.min.js:1
(anonymous) @ web3.min.js:1
(anonymous) @ inpage.js:1
Promise.finally (async)
_handle @ inpage.js:1
handle @ inpage.js:1
_rpcRequest @ inpage.js:1
sendAsync @ inpage.js:1
s.send @ web3.min.js:1
n @ web3.min.js:1
(anonymous) @ web3.min.js:1
u @ web3.min.js:1
(anonymous) @ web3.min.js:1
(anonymous) @ inpage.js:1
Promise.finally (async)
_handle @ inpage.js:1
handle @ inpage.js:1
_rpcRequest @ inpage.js:1
sendAsync @ inpage.js:1
s.send @ web3.min.js:1
n @ web3.min.js:1
t @ web3.min.js:1
t @ web3.min.js:1
o._executeMethod @ web3.min.js:1
(anonymous) @ main.js:24
dispatch @ jquery-3.4.1.min.js:2
v.handle @ jquery-3.4.1.min.js:2

This below is my Coinflip.sol code :point_down:

ragma solidity 0.5.12;

contract Coinflip {

  address public contractOwner;

  constructor() public {
      contractOwner = msg.sender;
  }

  modifier onlyOwner() {
      require(msg.sender == contractOwner, "You are not the owner");
      _;
  }

    uint public contractBalance;
    address public contractAddress;

    modifier costs(uint cost) {
        require(msg.value >= cost, "Minimum amount >= 0.01 ether");
        _;

    }

    event betPlaced(address user, uint bet, bool);
    event contractFunded(address contractOwner, uint);

    //Flip the Coin and check whether user won or lost;
    function flipCoin() public payable costs(0.01 ether) returns(bool) {
        require(address(this).balance >= msg.value, "The contract doesnt have enough balance to play right now. Come Back later");
        bool success;
        if (now % 2 == 0) {
            contractBalance += msg.value;
            success = false;
        }
        else if (now % 2 == 1){
            contractBalance -= msg.value;
            msg.sender.transfer(msg.value * 2);
            success = true;
        }
        //event to be emitted
        emit betPlaced(msg.sender, msg.value, success);
        return success;
    }

    function getBalance() public view returns(address, uint, uint) {
      return(address(this), address(this).balance, contractBalance);
    }

    // withdraw all funds possible only though contractOwner address;
    function withdrawAll() public onlyOwner returns(uint){
        msg.sender.transfer(address(this).balance);
        assert(address(this).balance == 0);
        return address(this).balance;
    }

    function fundContract() public payable onlyOwner returns(uint) {

        require(msg.value != 0);
        emit contractFunded(msg.sender, msg.value);
        return msg.value;
    }
}

and this below is my main.js. :point_down:

var web3 = new Web3(Web3.givenProvider);
var contractInstance;

$(document).ready(function(){
  window.ethereum.enable().then(function(accounts){
    contractInstance = new web3.eth.Contract(abi, "0x340c4A19652675fFf90C25Ba3C711a5a499b86b3", {from : accounts[0]});
    console.log(contractInstance);
    });

    var config1 = {
      value : web3.utils.toWei("0.5", "ether")
    }
    var config2 = {
      value : web3.utils.toWei("1", "ether")
    }

    var config3 = {
      value : web3.utils.toWei("2", "ether")
    }



    $("#open-door1").click(function(){
      contractInstance.methods.flipCoin().send(config1)
      .on("transactionHash", function(hash){
        console.log(hash);
      })
      .on("confirmation", function(confirmationNr){
        console.log(confirmationNr);
      })
      .on("receipt", function(receipt){
        console.log(receipt);
        alert("Funds received!");
        if(receipt.events.betPlaced.returnValues[2] === false){
            alert("You lost " +  " 0.5 Ether!");
        }
        else if(receipt.events.betPlaced.returnValues[2] === true){
            alert("You won "  + " 0.5 Ether!");
        }
      });

    });

    $("#open-door2").click(function(){
      contractInstance.methods.flipCoin().send(config2)
      .on("transactionHash", function(hash){
        console.log(hash);
      })
      .on("confirmation", function(confirmationNr){
        console.log(confirmationNr);
      })
      .on("receipt", function(receipt){
        console.log(receipt);
        alert("Funds received!");
        if(receipt.events.betPlaced.returnValues[2] === false){
            alert("You lost "  + " 1 Ether!");
        }
        else if(receipt.events.betPlaced.returnValues[2] === true){
            alert("You won "  + " 1 Ether!");
        }
      })
    });

    $("#open-door3").click(function(){
      contractInstance.methods.flipCoin().send(config3)
      .on("transactionHash", function(hash){
        console.log(hash);
      })
      .on("confirmation", function(confirmationNr){
        console.log(confirmationNr);
      })
      .on("receipt", function(receipt){
        console.log(receipt);
        if(receipt.events.betPlaced.returnValues[2] === false){
            alert("You lost " + " 2 Ether!");
        }
        else if(receipt.events.betPlaced.returnValues[2] === true){
            alert("You won "  + " 2 Ether!");
        }
      })
    });
});

and here below is my index.html :point_down:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>FlipCoin</title>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"
      integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
      crossorigin="anonymous"></script>
    <script type="text/javascript" src="./web3.min.js"></script>
    <script type="text/javascript" src="./abi.js"></script>
    <script type="text/javascript" src="./main.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

  </head>
  <body>
    <div class="jumbotron jumbotron-fluid">
      <div class="container">
        <h1 class="display-4">CoinFlip Dapp - </h1><h2> Web3's Most Happening
          "Fully Decentralized" Betting App</h2>
        <img src = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw4PDw8NDQ8ODg0NDQ8NDg4PDw8NDQ0PFREWFhYRFRUYHTQgGRolGxUVLTEhJiorOi4uFx8zODMsNygtLisBCgoKDg0OGxAQFy0lHyYrLTI1MC0tLTUrLS8rLy0wLS0tLS0tLS0tLy0tLysrLS0tKysvLS0uKy0tLSstLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAAAQIDBAUGBwj/xABCEAACAQMCAwQHBQYDCAMAAAABAgMABBESIQUTMQYiQVEUIzJhcYGRB0JSobEzYnKCosEVNJIkY3N0k7LR4UNTVP/EABoBAAIDAQEAAAAAAAAAAAAAAAADAQIEBQb/xAArEQADAAIBAwEHBAMAAAAAAAAAAQIDESEEEjFhEyJBUXGx8DJCocEFUoH/2gAMAwEAAhEDEQA/APDaKKKACiiigBaKKKAFpaSloAKWiloASlopaACilxSgUANpcU8LS6KnRGyPFGKft5j60beY+tT2sNjMUVJopCtRoNkdFOIpMVBI2ilooAbRS0lACUlOpKAEpKWkoAKSlpKACiiigAooooAKKKKACloooAKUUUtABS0lLQAUtAFPValIBoFPC1IqVKqVdQUdEISnhOg8ScADck+QHjVm0tZZpUt7dGlmkYKqqC2MnGTjoN+te2dh+wMNgBPPpnviMmQgGODfOlB59N/dtjxTnzziXqXx46yfQ4Ps19md5dBZbk+hQNuA66rlxjqI/u/P6V6Hwr7OuF24GYPSH/HctzPP7g7vj5V1aMNTKSM6RozsDJv3c+Z22+HnUskZ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onyDMS6NUWNFFa5EMYTSE0UVYBpNJRRVWWEoooqoBRRRQAUUUUAf/Z" alt = "Ether Image">
        <p class="lead">Win Double of What You Bet! </p>
      </div>
    </div>
    <div class="container">
      <div>
        <h2>Now time to Bet</h2>

        <button type="button" id="open-door1" class="btn btn-primary">0.5 ETH</button>
        <button type="button" id="open-door2" class="btn btn-primary">1 ETH</button>
        <button type="button" id="open-door3" class="btn btn-primary">2 ETH</button>
      </div>
    </div>
    <div class="jumbotron jumbotron-fluid">
      <div class="container">
        <img src ="https://media2.giphy.com/media/g7GDZf4NXsIpi/giphy.gif?cid=ecf05e477r1ngzmvq4si8tucvi9wizdx3acymzcielzg3sis&rid=giphy.gif , alt = "Money Door">


  </body>
</html>

Please can you inspect and let me know where I am going wrong and why Metamask is showing this error?
https://github.com/Suveett/coinFlip-Dapp.git
This is the full set of files on github :fu:
Thanks and regards

Su.Kal Crypto

Hi @Su.kal.Crypto

There might be a transaction stuck in your metamask due to low fees.

  • Open MetaMask;
  • Click on activity and check if you see a tx stuck
    Screenshot 2021-01-04 at 09.14.47

If that’s the case follow this guide: https://help.tokensets.com/en/articles/4089766-how-to-push-through-a-stuck-transaction

Hi @dan-i

There is no stuck transaction in My Metamask

Here is the screenshot :

Even etherscan doesn’t display a stuck transaction, rather it shows an undefined tx :

Lastly, even after several trials i just keep noticing the following error :

inpage.js:1 MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC ‘{“value”:{“code”:-32603,“data”:{“message”:“the tx doesn’t have the correct nonce. account has nonce of: 14 tx has nonce of: 20”,“code”:-32000,“data”:{“stack”:“Error: \n at validateNonce (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/statemanager.js:964:11)\n at blockchain.getQueuedNonce (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/statemanager.js:973:7)\n at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/blockchain_double.js:436:5\n at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:77:5\n at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:461:14\n at Object.return (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:485:9)\n at processNode (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:285:30)\n at processNode (/Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:521:5)\n at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:516:13\n at /Volumes/Ganache 2.1.1/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/baseTrie.js:180:7\n at _combinedTickCallback (internal/process/next_tick.js:131:7)\n at process._tickCallback (internal/process/next_tick.js:180:9)”,“name”:“TXRejectedError”}}}}’ Object

Also, if you will see below that after changing advanced settings nonce the following is displayed :fu:


I am really unable to understand, kindly help :pray:

thanks and Regards

Su.kal Crypto

Hi @Su.kal.Crypto

The transaction does not show up in etherscan because you are using your local Ganache blockchain and not the mainnet.
I also notice that in your screenshot you are using accounts[3] and that the last transaction from accounts[3] was the 27th of December.
Are you sure you are triggering a new transaction with accounts[3] and not accounts[1]?

Screenshot 2021-01-05 at 09.57.38

Open Metamask, select accounts[1] and check again if there is a tx stuck there.
Screenshot 2021-01-05 at 09.58.39

Feel free to provide a screenshot.

Happy learning,
Dani

Dear @dan-i

Yes I am certain i am triggering the transaction from accounts[3]- 0x687f17fe288c4AD8Fa4A918239DaA75b79062B75

see Ganache Screenshot below, and also I am no stuck transactions in accounts[1] and accounts[2]. Its getting really strange :point_down:



kindly await your further instructions :pray:
thanks and Regards

su.kal Crypto

Hi @Su.kal.Crypto

Try to reset MetaMask:

Click the account icon on the top-right corner of MetaMask
Select Settings
Select Advanced
Scroll down and click Reset Account

Then restart ganache (possibly also use a new workspace) and retry.

Screenshot 2021-01-05 at 16.16.50

1 Like

Hi @dan-i

I did exactly as you said(in fact my Metamask account wasn’t getting reset so i removed Metamask chrome extension and then reloaded it and even started a new workspace in ganache) but unfortunately now its showing the below error:

Can you tell me where Am i Going wrong ?

Also, after doing some trial errors, i am getting these below messages: :point_down:

Thanks and Regards

Su.kal Crypto

Hi @Su.kal.Crypto

Try to convert your contract address to checksum by using this command: Web3.utils.toChecksumAddress(*your address*)

Regards

Hey @dan-i

Thanks for Help. Now it works.
But encountering now another set of problems. Actually i reset my Metamask again and reconfigured the accounts 3 and also restarted a new workplace in ganache. sending the screenshots below :point_down:


Let me know where I am still going wrong. Just out of trial and error I have actually learnt so much through this course, but being non technical it always seems insufficient :grinning:

Thanks and Regards

Su.Kal Crypto

The error is related to a require statement in your contract that fails.
Once you fix that issue is should work.

Hey @dan-i

Its really getting frustrating now…
I have tried all permutations and combinations

Kindly please help :pray:

Below is my code in Github :point_down:
https://github.com/Suveett/coinFlip-Dapp.git
https://github.com/Suveett/coinFlip-Dapp.git
Kindly let me know where i am going run, coz now i am really scratching my Head… :face_with_head_bandage:
I managed to solve the Revert error, now having other errors and its taking a heavy toll on me now.
Somehow i have also not become familiar with the Custom Nonce issue, even inspite of going through your recommended readings
thanks and regards
su.kal Crypto

Hi @Su.kal.Crypto

I took a look at your repo.
Are you sure you pushed the right files on GitHub?

In your main.js I see $("#flip_button").click(flipCoin); but you do not have a button called flip_button in your html.

Also if I add it then I get other web3 errors related to the type of the variable bet that should be a string.

Can you double check, push the right files and let me know?

Regards,
Dani

Hi Dani

I am really sorry. I had made changes on Index.html and later forgot to commit the same changes on Github files.

I have now put in the right version of index.html on Github.

I am really Sorry for the debacle.

Now you may please check and revert . Most probably my errors are coming from the metamask side ( RPC error or Maybe Nonce - and honestly i haven’t been able to figure out Metamask configs well until now). As far as the JS code is concerned, I think the code is fine and should work , although since I am not a skilled HTML developer my website is not flashy ( I have just learnt the few basics what Ivan explained in course and also the CS-50 Video showed - If you suggest some other courses I should take, Let me know , will do the same)

https://github.com/Suveett/coinFlip-Dapp.git

Thanks and Regards

su.kal Crypto

Hey @Su.kal.Crypto

I am really Sorry for the debacle.

No worries at all :slight_smile:

Completely delete the folder build in your project.

Screenshot 2021-01-08 at 16.48.27

Now fix this button in your main.js

    $("#flip_button").click( () => {
      flipCoin();
    });

Again migrate your project:

truffle develop
migrate --reset

Copy and save the new contract address in your main.js

Let me know!

Hey Dani

Did everything exactly as you told me.
Now getting the below error:

I changed the address too in my main.js

its showing some Gas error or some error in web3.main.js

Can you really tell me why this is happening ?

should i remove my web3.min.js file too ? and add again ?
should i use the web3.min.js file from the dapp template that Filip had sent during the course ?

I am getting confused now, although it’s good that i am getting to experience these difficulties, makes my resolve to learn even stronger.

Metamask is giving me a Hard time. Until Metamask pop up/ error , everything is running fine
Thanks and Regards

Su.kal

Hey @Su.kal.Crypto

There is an error in the address you are using in your main.js
Screenshot 2021-01-08 at 17.27.43

Use this piece of code

  window.ethereum.enable().then(function(accounts){
    contractInstance = new web3.eth.Contract(abi,"0xafba9088A36f0A4AeA75eD9CFCF79857A7Ab3fdB", {from : accounts[0]});
    console.log(`Use contract address: ${contractInstance._address}`);
    });

Change the address above with your contract address.

Refresh the webpage where localhost is open and make sure that the address displayed matches your contract address.

Screenshot 2021-01-08 at 17.40.19

Then you should be able to play

Hey Thanks a Ton Dani

Now its all running Fine… Really Really appreciate your support :pray:

Su.kal Crypto

1 Like

DevTools failed to load SourceMap: Could not load content for chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/sourcemaps/disable-console.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME

I get the above error when I try to interact with the console, when disabling js and css in settings it dissapears but I still can’t interact with the console it’s just empty. Any help guys=

Hey @Lamar

That warning is not related to your dapp and should not create any problem to your application :slight_smile:

I googled it, take a look here: https://stackoverflow.com/questions/61205390/devtools-failed-to-load-sourcemap-could-not-load-content

If you have issue with your code, create a git repo and push it there so that I can have a look.

Happy learning,
Dani

Thanks Dani, I’ve checked that out already, but I still can’t interact with the console, it’s all empty after the error messages, dunno why?