TransWikia.com

web3.eth.Contract with Web3 1.3.0 does not seem to work

Ethereum Asked on February 16, 2021

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.

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

Correct answer by goodvibration on February 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP