0

I'm able to create an instance of a smart contract that I know works in Ganache using Truffle. But in my Javascript Nodejs app, with the syntax "let contractInstance = new web3.eth.Contract(abi)", when I call the contractInstance method "contractInstance.ownerOf", it says "ownerOf" is not a function. But I can see this in the ABI. Also get an undefined when I console log "contractInstance.address". Been "googling" this issue for hours and I'm coming up with nothing. Any help is greatly appreciated! Thanks.

1

The syntax contractInstance.contractMethod is valid on web3.js v0.x.

Starting from web3.js v1.0, the syntax is contractInstance.methods.contractMethod.

And in order to get the contract instance address, you can use contractInstance._address.

2
  • Thank you. This worked. – Jay Dec 14 '20 at 13:23
  • @Jay: You're welcome. Feel free to accept the answer by clicking on the V next to it. – goodvibration Dec 14 '20 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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