0

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!

1
  • I don't think my function is not being called correctly - so you think that it IS being called correctly? Apr 15, 2020 at 21:06

2 Answers 2

0

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) => {
    ...
});
0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.