I had a similar issue when you remigrate the people contract the contract address changes so you need to update the
const contractAddress = "0xb4fd34666e8413b732AAA482AAfE60bAF2D82710";
then it should work.
I had a similar issue when you remigrate the people contract the contract address changes so you need to update the
const contractAddress = "0xb4fd34666e8413b732AAA482AAfE60bAF2D82710";
then it should work.
yes, also updating the abi.js file is crucial as well
Whenever you deploy a new contract, you need to make sure that you also update the contractAddress
in your JS file otherwise your web3 instance will communicate with the wrong contract.
Same thing for the abi, if you change something in your contract (maybe you add or remove a function), you then need to copy and use the new contract abi, otherwise your web3 instance will not know about the changes you made to your contract.
Regards,
Dani
trueâŚtrueâŚI found out the hard way, lol
Hi,
I have some wierd issue here. Iâm running ganache and truffle, but when I import one of the accounts from ganache (that has 100 ETH) to Metamask, it shows this balance which I really donât understand why:
Thanks
Hello. I need help here.
Donât know what I did wrong but when I press âadd dataâ on the dapp nothing happens. The alert doesnât come up.
Hey @Elekko
Is your metamask connected to ganache?
Double check it and share also a print screen of ganache so that we can verify.
Regards,
Dani
Hi @KlodyCodez
There are syntax errors in your code.
VS code is signalling that with a vertical red mark, check the window.ethereum.enable, you are missing a closing parenthesis.
Try to fix and please post the code here instead of a screenshot so that itâs much faster for us to just copy/paste it.
Cheers,
Dani
HI dan-i,
I double checked and I see that it is connected, I used the first account in Ganache (I have also tried other). I suspect this is some issue with Ganache? Iâm running on Ubuntu 20.04:
Hey @Elekko
Really strange try to create a new project in Ganache and link your truffle-config from scratch and check again.
Cheers,
Dani
I did that, same issue. However it works with âtruffle developâ, but had to degrade my NodeJS from v14 to v10. Quite pity all this⌠Might be a bug running Ganache on Ubuntu 20.04
Hey @dan-i, not sure what Iâm doing wrong here but I canât get the alert in the inputData() function to appear on click. Would you be able to check my code? I have ganache and python server running, and metamask working. Thanks!
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
$(document).ready(function() {
//brings up metamask ask for permission from browser, then passes accounts in metamask to promise function
window.ethereum.enable().then(function(accounts) {
//contract instance of abi template containing function definitions, address of contract, and default sender (metamask account 0)
contractInstance = new web3.eth.Contract(abi, "0x7961a7dDde5D3B90d4FA4f8c1eA1B62DAE275Ddf", {from: accounts[0]} );
//console.log(contractInstance);
});
$("#add_data_button").click(inputData);
});
function inputData(){
alert("hello!");
console.log("hello!");
/*
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);
*/
}
Hi Frank,
thanks for the info, I had the same problem.
Daniel
@filip
I know this is super simple, but I cannot view the contract in the console. Iâm getting âUncaught ReferenceError: Web3 is not definedâ. Problem is that it IS DEFINED!
my code for main.js:
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
var abi = [...]
$(document).ready(function() {
window.ethereum.enable().then((accounts) => {
contractInstance = new web3.eth.Contract(abi, "0x8e3650Fb6d8BB6142Bc6C5c624fDCFc2Cf9b75E8", { from: accounts[0] });
console.log(contractInstance);
});
});
How can I solve this? I have web3.min.js linked in index.html. Iâve also done npm install web3 just because. Please assist!
figured it out. web3.min.js needed to come BEFORE main.js in the src links in index.html. Just in case anyone else had this issue.
duhâŚ