const Web3 = require('web3'); const web3 = new Web3(process.env.NEXT_PUBLIC_INFURA_ENDPOINT); const useReadContract = (contractAddress, tokenId) => { web3.eth.handleRevert = true; const abi = [ { "constant": true, "inputs": [ { "name": "_tokenId", "type": "uint256" } ], "name": "tokenURI", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function", }, ]; new web3.eth.Contract(abi, contractAddress).methods.tokenURI(tokenId).call() .then(res => { // console.log(res); return res; }) .catch(err => { console.log(err); }); return undefined; } export { useReadContract };