Dapp Introduction

Thanks for clarifying. Originally I thought it was an error as nothing was happening on the page when I clicked on the add data button, it was obviously due to having scripts turned off as all good now. Cheers all the same

Hey @Taha!
I just posted that I got it to work, however as soon as I looked at the localhost:8000 webpage there were 118 errers! This is so fustrating! :tired_face:
I looked and I have version 8.0.5 for metamask.
This is the bigest problem Iā€™ve had in a vairy long time.
Thanks!

Hi @JRB

What kind of errors ? Are you talking about this errors ?

Can you share a github repo we will try to find out what is the issue here.

Do you have file of images called ā€œCRYPTO_WHITELISTā€ or ā€œBLOCK_PAGE_WHITELISTā€ or is it metamask errors ?

Is your application working ?

2 Likes

My javascript files (abi and main) clearly arent being picked up by the html file despite various console.logs and whatver. My functions from ā€œmain.jsā€ are not calling. However, the contract(s) are deployed on ganache. I feel the issue is somehere in the web3 library linking but i cant say anything conclusive. I really have 0 clue as to a fix.

<title>People</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">
<div class="jumbotron jumbotron-fluid">

  <div class="container">
    <h1 class="display-4">People Dapp</h1>
    <p class="lead">Expose your data to the world! </p>
  </div>

</div>


<div class="container">
  <div>
    <h2>Add Your Data</h2>

    <div class="input-group mb-3">
      <input type="text" class="form-control" id="name_input" placeholder="Name" >
    </div>

    <div class="input-group mb-3">
      <input type="number" class="form-control" id="age_input" placeholder="Age">
    </div>

    <div class="input-group mb-3">
      <input type="text" class="form-control" id="height_input" placeholder="Height" >
    </div>

    <button type="button" id="add_data_button" class="btn btn-primary">Add Data</button>
  </div>

  <div>
    <h2>Get Your Data</h2>
    <div>
      Name: <span id="name_output"></span>
    </div>
    <div>
      Age: <span id="age_output"></span>
    </div>
    <div>
      Height: <span id="height_output"></span>
    </div>
    <button type="button" id="get_data_button" class="btn btn-primary">Get Data</button>
  </div>
</div>

I am receiving the following error in console:

jquery-3.4.1.min.js:2 jQuery.Deferred exception: Cannot read property ā€˜enableā€™ of undefined TypeError: Cannot read property ā€˜enableā€™ of undefined
at HTMLDocument. (http://localhost:8000/main.js:4:21)
at e (https://code.jquery.com/jquery-3.4.1.min.js:2:29453)
at t (https://code.jquery.com/jquery-3.4.1.min.js:2:29755) undefined
k.Deferred.exceptionHook @ jquery-3.4.1.min.js:2
jquery-3.4.1.min.js:2 Uncaught TypeError: Cannot read property ā€˜enableā€™ of undefined
at HTMLDocument. (main.js:4)
at e (jquery-3.4.1.min.js:2)
at t (jquery-3.4.1.min.js:2)

Edit: my code is exactly equal to Filips code for dapp-template on github.

Hey @gabba!
Iā€™m sorry it took so long to get back to you. I was at a week long camp and did not have access to a laptop.
The errers that you showed in the img are the exact errers that iā€™m getting. I am getting CRYPTO_WHITELIST and BLOCK_PAGE_WHITELIST and metamask errers. Iā€™m prety sure that the metamask errers are just it complaining that I denied it access with metamask.
Here is the errers that iā€™m getting


Allso, for some reason there are 126 errers!
Allso, it takes at least 1 minute for the errers to pop-up.
I just got finished with the gethub repo.

I hop that this helps.
Thanks!

@Archie_Smyth
The error says your enable variable/const is not created (defined) any where and you are trying to use it :slight_smile:

please defined it:
For example: var enable

2 Likes

Hi @JRB
Itā€™s working for me

Where did you save your files ? I mean in which folder .
I think you donā€™t have the permission to access this folder from your browser.
Can you try to copy all this file on your desktop and try again to open it from there (by double clicking on index.html ) ?

4 Likes

Hey @gabba, @Taha!
I finaly works! I did what you said and moved the dapp folder out of the ethereum-course-advanced folder and then only 2 errers poped up. And they where the metamask errers.
Thank you for all of your help!

Edit: I allso found out that I have to allow metamask to connect in order to get the contract instance log. Now the 2 metamask errers have gone.

1 Like

I keep getting these errors when I try to send the trx. First I see an alert in metamask before I even confirm. After I confirm I then see the big error in the consoleā€¦ Anyone have any ideas ?

ok finally solvedā€¦ I used the reset account feature in metamask that seems to have solved it :slight_smile:

1 Like

@Emmett
Amazing! Great to see you resolve the issue by yourself.
Yeah, there are few cryptic errors in metamask sometimes and can be sorted by resetting account or even changing the broswer. :slight_smile:

Happy coding

1 Like

Thank you dearly for the assistance @Taha. However, I have fixed my issue since now. I believe the issue was something to do with my file/folder structure becuase, I downloaded Filipā€™s finished project, and now itā€™s working smoothly as expected. Have a good day Taha.

1 Like

Hey @gabba!
As you know I just got finished with the 126 errers. However now I canā€™t get the add_data_button to work. As in the pop-up wonā€™t work.
Iā€™m sorry if iā€™m takeing up too much of your time.
Thanks!

@JRB
Me and @gabba are assigned mentors, so we all work to answer to your queries.
Please feel free to take our time :slight_smile:

try debugging the add_data_button with the help of console.log and alert.
Check the line where the program stops responding.

2 Likes

Finding some problems. I believe Iā€™ve followed all the setup for python correctly, itā€™s running and the index.html loads via the localhost:8000 url in chrome (plus believe my meta account/contract address setup is corect too) . However in the video is shown that the console view the small o (in attached image) but I donā€™t see that. Plus Iā€™ve added the button alert which should trigger a popup but nothing happens. Any ideas folks?

@iceman007
Thanks for reaching out!
If you are able to load index.html via the localhost:8000 then you are correctly running the python server.

The console image you have shared repressed the connection status of your application server with ganache/metamask

Since, you are not getting the ā€œsmall oā€, first you need to check your application server connection with ganache/metamask.

If it doesnā€™t work, better you share your code for review :slight_smile:

1 Like

Ahh solved.

Really strange but I was using Chrome so decided to install firefox/metamask with all same account settings etc and the test popup worked no problem. Hard to say why it didnt work in Chrome though

Thanks Taha for your help

1 Like

Hey @Taha!
Question: Do you mean replace the alert with a console.log?

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

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

});

function inputData(){
  //alert("inputdata");
  console.log("inputdata");
}

I did that however inputdata did not show up in the console.

Allso, these warnings might mean something, of course they could be nothing but I thought they could be causing the problem.


Thanks!