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 Answer 1

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.

0

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.