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!
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 ?
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
please defined it:
For example: var enable
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 ) ?
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.
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
@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.
Happy coding
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.
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
try debugging the add_data_button with the help of console.log and alert.
Check the line where the program stops responding.
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
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
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!