This is my simple js code (without api). I try to do my first steps with js and web3 and the goal is to fetch data from the OMG network, a very simple task, but for some reason it is not working. I tried to do some variations like with brackets with the methods.name eg.
I am getting the following errors:
TypeError: TestContract.name is not a function
and
TypeError: Cannot read properties of undefined (reading 'call')
the Code:
const { Web3 } = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/v3/fa26d14d8e984def8d480be40582be12"));
const address = "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07"
const abi = [
...
]
const TestContract = new web3.eth.Contract(abi, address);
async function getTokenName() {
let tokenName = await TestContract.name().call();
console.log(tokenName)
}
getTokenName()
Thanks in advance!