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
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
.