Thank you very much for your help!
I tried it again today, but I experienced some other problem with MetaMask, my transaction would not go through:
I have no idea why, because it went through last time…
Thank you very much for your help!
I tried it again today, but I experienced some other problem with MetaMask, my transaction would not go through:
I have no idea why, because it went through last time…
Might be because of a requirement in the smart contract. You could try to if another function of the contract can be called, or remove the requirements, to test if that works.
Thank you!
I removed requirements, but it is still the same, transaction would not go through. I used Filip’s sample code from Github, so it should have no problems. Thank you for your help.
I had that problem before, but never able to solve it.
@Filip please help!
The transaction went through last time, but for the past two days I am back where I started one months ago. Contract code I copied your Github sample code.
Hi @Golden_Pig_Coin
I went to this error and it drives me crazy last time !!
But i discover that it was a metamask issue … I had to disable and enable metamask extension, i switched to an other network and i also re deploy the contract and it works fine.
Their is almost no info on this error code online …
I also though it was coming from my smart contract but it’s definitely a metamask internal error.
Resetting everything is the best way to get ride of it
@gabba
Thank you very much for the tip! I really appreciate your help!
I deleted the extension and added it again and added Ganache network again, imported account again, finally it works now!
And my console log also works fine now, showing transaction hash and blockhash. I do not know if it has anything to do with MetaMask though.
Question/Issue :
During the lesson creating a contract instance i noticed my code doesn’t execute correctly in chrome but does when in firefox and when i go in the debugger on chrome and view the main.js file i can see that it is missing 2 lines of code while when i look at it in firefox the code is all present in the debugger and everything is good. Any ideas on what could cause chrome not to pick up the changes? I’ve tried restarting the server and recompiling my code no luck though
You are right. It doesn’t matter what you all it. Can be x, y or anything. But I would be careful if I already have made variable called x.
I always use CTRL + F5. This reloads the chrome page fully for me. Only F5 or refresh button isnt doing the same job.
I have some questions about the Creating a Contract Instance video:
1.: Filip said that window.ethereum.enable() brings up a box for the user from metamask, that will ask the user for permission for the webpage to access metamask. If the user doesn’t have metamask, does that mean he cannot use our Dapp? Do all the Dapps that we build have the requirement for the user to have metamask?
2.: How is the contract address beeing generated? Is it by hashing all the data in our files? I tested, that everytime I change the code, the address is different, but it is not different if I reboot ganache over and over. If it is created by hashing the code, why does the following happen:
I had my code working, entered in the truffle console: migrate --reset, and then I got my contract address and safed it somewhere. Then I added in the people.sol file just an empty line of code between the variables and did migrate --reset again, and of course got a different hash as address. Then, I deleted this empty line again so that the code looks exactly like it was before, and for some reason I didnt got the same address hash like the one i had in the beginning. Why is that? Does the abi change a bit everytime i redeploy the contract? I hope thats not the case lol
Thanks in advance!
@filip
Hi @illyushin
1- window.ethereum.enable() have been implemented for privacy purpose to avoid malicious app to access information from your wallet extension, this article explain it very well
Before this implementation browser wallet were injecting a provider with user accounts information, you can also read the eip 1102 which explain it more in deep:
So yes, if the user doesn’t allow the Dapp to communicate with his wallet, he will not be able to sign a transaction.
Your users will have to install an extension or using a browser with a builtin wallet (like brave) otherwise you will have no way to send a transaction via web3js using your abi.
You could still send raw transaction to the smartContract directly to the blockchain but it’s not really user friendly and if the user don’t have your abi it ll be complicated for him to know how your smart contract works.
2- Very interesting question, i just learn about it because of your question
it seems that it is generated based from the address of its creator ( sender
) and how many transactions the creator has sent ( nonce
) .
source :
A new op code have also been implemented CREATE2 which i have to read about it more in deep, it seems to work a bit differently.
It makes sense in your case because every time you are creating a new contract even the code is the same your nonce is incremented so the hash change.
If you reboot ganache you will have a fresh account with a nonce a 0 so the first contract will have the same address.
I hope it helps you
@gabba and @Golden_Pig_Coin this Metamask error and yesterday’s error “Uncaught (in promise)” are wasting me hours. For the uncaught error, I just rewrote the code and watched the videos again… For the Metamask I was trying to avoid deleting the extension so after redeploying the contract (nothing changed) I just went to Metamask, “Settings”, “Advanced” and “Reset Account”. Basically, the transaction history is deleted so it’s kind of a “fresh start” for Metamask. The ganache network is still connected and the error is finally gone. So, for future people, try “Reset Account”, it might solve your error.
Hi @pedromndias, thank you for the tip, I will remember that.
I deleted the extension and added it again every time the error occurred, which wasted a lot of time!
HI, I’m not able to call inputData function. any ideas which element doesn’t exist?
$(document).ready(function() {
window.ethereum.enable().then(function(accounts){
contractInstance = new web3.eth.Contract(abi, “0xC96737B20852F67C04eC03fe003B818890E950eF”, {from: accounts[0]});
console.log(contractInstance);
});
$("#add_data_button").click(inputData)
});
function inputData(){
alert(“Harris”);
//var name =$("#name_input").val();
//var age =$("#age_input").val();
// var height =$("#height_input").val();
}
Hi @filip
I have issues with the Project setup video and Creating a Contract instance video.
I dont know if i missed a video but i dont have python installed and i dont have the People.json file so i can copy the info to the abi,js file.
I tried to use google to instal python and run it in the powershell with no succes. Im using w7 and used this tuto to edid the path
http://lingwars.github.io/blog/instalar-python-en-windows-7.html
Any ideas?
Hi.
I think it would be easier if you download directly from python.org or follow this link
Try to run that file, and it should install properly.
Ivo
Thanks @ivga80
I found this solution if you cant run python -m SimpleHTTPServer on windows.
I guess windows users have to search different wais to use python and future commands to make this work
Hi, I can’t call the createPerson function i keep getting this error:
I’ve checked the function name, the parameters, the contract address and the abi. It all looks fine to me.
This is my code:
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
$(document).ready(function() {
window.ethereum.enable().then(function(accounts){
contractInstance = new web3.eth.Contract(abi,"0xD7360622E256C6d6DAD4d251A0e9059001Eb01B7",{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);
}
Can anyone help me?
EDIT: i’ve tried to pass age and height by writing them directly in the createPerson method and it worked.
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
$(document).ready(function() {
window.ethereum.enable().then(function(accounts){
contractInstance = new web3.eth.Contract(abi,"0xD7360622E256C6d6DAD4d251A0e9059001Eb01B7",{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,10,10).send(config);
}
So it looks like i’m trying to pass two strings(age and height) where the parameters should be uint.
Did i forgot some important concept from the previous lessons??
What application are you using to edit index.html / main.js ?
Thanks …
@penneAllaPuttanesca when you define the age and height variables, you need to add the ‘#’ to let jquery know that you are using identifiers. You did it for the name variable.