Yo @dan-i,
Appreciate your help
Hey @Marcus_Tang
You need to test your dapp using a server.
run a python simple http server and try there, it will work.
Yo @dan-i,
I donât quite understand what you mean, cause I am very new towards this kind of things. Appreciate your help.
Hey @Marcus_Tang
Filip explains it step by step here: https://academy.ivanontech.com/products/ethereum-smart-contract-programming-201/categories/1993956/posts/6668112
Let me know if you have questions.
Cheers,
Dani
Hey @Marcus_Tang
Using the Terminal/Powershell you first need to navigate into your project directory, once there you can run your python server.
Let me know if that works
Dani
Guys, those kind of errors generally thrown because of typos, problem like claimed as âfromâ parameter which belongs to contractInstance object were never been used in the code, so you go back and forth at the code hundred times but wonât see the f r o m word possibly were staying there as f o r m. Instead of cleaning history of your log, which would necessary later, maybe itâs better to check the code like somebody elseâs. fyi
Hey @thecil!
I have a problem with getting my localhost:8000 to save the changes that I make in the code. I put in the changes, than save. Then I reload the webpage. However the changes do not show up. Then I wait for awile (perhaps an hour or so) then the changes show up. Taha tryed to help but he couldnât figure it out. He allso checked my code and every thing checked out. I was wondering if you could help me with this issue.
Thanks!
Hey @JRB
It might happen and that does not probably indeed depend by your code.
Have you tried to restart the localhost server after a change?
Cheers,
Dani
Hi @JRB ,
I had the same problem.
If you are using Chrome, you can click and hold the Refresh icon in front of the address bar, and a box will pop up, and you can choose to âHard Reloadâ or even âEmpty Cache and Hard Reloadâ:
Hi guys,
Iâm having a trouble with my main.js file. Whenever I reload the localport:8000, the alert commands donât appear like what is seen in Filipâs video. Below is my main.js code:
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
alert("hello testing");
$(document).ready(function() {
window.ethereum.enable().then(function(accounts){
contractInstance = new web3.eth.Contract(abi, "0x10CDdD67A27472BE68d917aE41c7B5208F9bc16C", {from: accounts[0]});
console.log(contractInstance);
});
$("#add_data_button").click(inputData)
});
function inputData(){
alert("Input Data!");
}
And my html:
Is there anything wrong with the linking of the files? Do I have to put the dapp template folder inside the People Folder? I have the dapp template and the People folder under one parent directory.
EDIT: Now the Metamask isnât working also. An hr ago it was working perfectly fine.
Thank you mentors for being patient!
Hi guys, in case anyoneâs experiencing the same error: I tried duplicating the main.js file and deleted the old one and it worked fine now. Not sure what the problem was lol but itâs not stupid if it works haha
What works for me, if i get any issues, is change the name of the pointer to the js file on the html page, reload the web page so that it registers a change in files (and throws a 404 error in the console as it doesnât recognise the file) then go and change the name of the actual js file to match the new pointer name (from the html page). Then when you reload the webpage it reads the newly named file completely and correctly. I think it has something to do with the state of the files when you start the server and it doesnât necessarily pick up changes unless you reload the server or change directory names - not sure really, but changing file names seems to force it to read the file correctly - I guess thatâs what you kind of did with duplicating the file. I read in an earlier post something about installing nodemon that will watch for file changes Also, if you make any significant changes or redeploy the contract with a new migration and contract address and so on, Metamask will probably throw errors. I have found just resetting the account in the Metmask settings does the trick. I am now at a point where if my Dapp or Metamask doesnât work properly after any changes (but Iâm sure it should be working) then I just rename the files and reset the Metamask account. Works a treat, Iâm sure there are better ways to handle this, but as a noob, I do whatever works for me haha. Good luck
Hi, Iâm getting this Metamask error when trying to add a person:
It says âALERT: Transaction error. An exception in the contract code ocurredâ
Inspecting the website, I get this error:
Any help on what could be causing this issue? May it be a Metamask issue?
Here is the code, which should be exactly the same as Filip wrote in the tutorial:
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
$(document).ready(function() {
window.ethereum.enable().then(function(accounts){
contractInstance = new web3.eth.Contract(abi, "0x8Ced647EDA532657360B429bB63AFe8598BaE0F5", {from: accounts[0]});
console.log(contractInstance)
});
$("#add_data_button").click(inputData)
});
function inputData(){
var name = $("#name_input").val();
var age= $("#age_input").val();
var height= $("#height_input").val();
var config = {
value: web3.utils.toWei("1", "ether")
}
contractInstance.methods.createPerson(name, age, height).send(config)
.on("transactionHash", function(hash){
console.log(hash);
})
.on("confirmation", function(confirmationNr){
console.log(confirmationNr);
})
.on("receipt",function(receipt){
console.log(receipt);
alert("Done");
})
}
Hey @alegarap
I would need to check your contract, it seems like you are hitting a revert().
Can you upload your project to GitHub and give me the link to it?
Happy coding,
Dani
did understand why? I had the same problem and just writing py make it work!
On the Project Setup Video, I could not get the command âpython - m http.serverâ to do anything for me in the command line interface, despite setting the environment variable to the python path.
I am on Windows 10 64x, with Python 3.9 installed.
After some Googling I found the suggestion of using âpyâ instead of âpythonâ in the command, so:
py - m http.server
This worked for me. Hopefully this will be helpful for someone else.
Good one
Thanks for sharing,
Dani