Delete and reinstalling truffle config didn’t work but I just switched the solidity version in the code to 0.5.8 instead of 0.5.12 that the course is taught in and that worked in being abled to deploy Helloworld Contract…
However, in working on the Dapp Template for preparation for the Project Phase and assignment, I am getting this error messsage in the browser console, any idea how I can handle this or why it is throwing this error?
Uncaught TypeError: contractInstance.methods.createPerson is not a function
at HTMLButtonElement.inputData (main.js:17)
at HTMLButtonElement.dispatch (jquery-3.4.1.min.js:2)
at HTMLButtonElement.v.handle (jquery-3.4.1.min.js:2)
pageHook.js:42704 [Sep 23, 07:40:28 am] [pageHook]: [INFO]: TronLink initiated
inpage.js:1 MetaMask: MetaMask will soon stop reloading pages on network change.
For more information, see: https://docs.metamask.io/guide/ethereum-provider.html#ethereum-autorefreshonnetworkchange
Set ‘ethereum.autoRefreshOnNetworkChange’ to ‘false’ to silence this warning.
(anonymous) @ inpage.js:1
11main.js:17 Uncaught TypeError: contractInstance.methods.createPerson is not a function
at HTMLButtonElement.inputData (main.js:17)
at HTMLButtonElement.dispatch (jquery-3.4.1.min.js:2)
at HTMLButtonElement.v.handle (jquery-3.4.1.min.js:2)
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
$(document).ready(function() {
window.ethereum.enable().then(function(accounts){
contractInstance = new web3.eth.Contract(window.abi, "0x0f2ACEbB46651f6e8161d78897DF1b51CD1F3Ff9", {from: accounts[0]});
});
$("#get_data_button").click(fetchAndDisplay);
$("#add_data_button").click(inputData);
});
function inputData(){
var name = $("#name_input").val();
var age = $("#age_input").val();
var height = $("#height_input").val();
contractInstance.methods.createPerson(name, age, height).send({value: web3.utils.toWei("1", "ether")})
.on('transactionHash', function(hash){
console.log("tx hash");
})
.on('confirmation', function(confirmationNumber, receipt){
console.log("conf");
})
.on('receipt', function(receipt){
console.log(receipt);
})
}
function fetchAndDisplay(){
contractInstance.methods.getPerson().call().then(function(res){
displayInfo(res);
});
}
function displayInfo(res){
$("#name_output").text(res["name"]);
$("#age_output").text(res["age"]);
$("#height_output").text(res["height"]);
}