I am trying to call a function from my back-end to my front-end. I know that my contract is deploying, however, I don't think my function is not being called correctly. My code is provided below. Does anyone know how I could fix this? Help would be insanely appreciated!
2 Answers
Since function createChallenge
changes the state of your contract, you should execute it with send
instead of call
(similarly to how you deploy your contract):
this.GameChangerInstance.methods.createChallenge("name", "description", 10, 10).send({
from: account,
gas: ...
}).then((receipt) => {
...
});
let contractInstance=new web3.eth.Contract(abi,"contract address",{from:accounts[0]});
contractInstance.function();
Hey there :)
I'm using this to interact with a contract with contracts throw web3js with my frnt-end.
P.S:acocunts[0] is just the main account .
Hope help you!
I don't think my function is not being called correctly
- so you think that it IS being called correctly?