'Parsing error: Unterminated string constant while using Smart Contract ABI
I am following the tutorial: https://youtu.be/WZWCzsB1xUE
and the error state occurs at: 50:00
I have checked multiple times using "", yet problem remains unsolved. Help would be appreciated as I am new to JS and ReactJS. The contract is deployed on polygon testnet with Moralis server support and using the Ethereum bolierplate Can anybody point out if any silly mistake?
const [contractABI, setContractABI] = useState('[
{
"inputs": [
{
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "price",
"type": "uint256"
}
],
"name": "createMarketItem",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
}
],
"name": "createMarketSale",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "seller",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "sold",
"type": "bool"
}
],
"name": "MarketItemCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "MarketItemSold",
"type": "event"
},
{
"inputs": [],
"name": "fetchMarketItems",
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
},
{
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "seller",
"type": "address"
},
{
"internalType": "address payable",
"name": "owner",
"type": "address"
},
{
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"internalType": "bool",
"name": "sold",
"type": "bool"
}
],
"internalType": "struct marketPlaceBoilerPlate.MarketItem[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]');
const [marketAddress, setMarketAddress] = useState();
Error:
"resource": "/c:/ethereum-nft-marketplace-boilerplate/src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "eslint",
"severity": 8,
"message": "Parsing error: Unterminated string constant.\n\n 7 | const [walletAddress, setWalletAddress] = useState();\n 8 | const [chainId, setChainId] = useState(); \n> 9 | const [contractABI, setContractABI] = useState('[\n | ^\n 10 | {\n 11 | \"inputs\": [\n 12 | {",
"source": "eslint",
"startLineNumber": 9,
"startColumn": 50,
"endLineNumber": 9,
"endColumn": 50
},{
"resource": "/c:ethereum-nft-marketplace-boilerplate/src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1002",
"severity": 8,
"message": "Unterminated string literal.",
"source": "ts",
"startLineNumber": 9,
"startColumn": 52,
"endLineNumber": 9,
"endColumn": 52
},{
"resource": "/c:src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "',' expected.",
"source": "ts",
"startLineNumber": 10,
"startColumn": 5,
"endLineNumber": 10,
"endColumn": 6
},{
"resource": "/c:/src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "',' expected.",
"source": "ts",
"startLineNumber": 187,
"startColumn": 3,
"endLineNumber": 187,
"endColumn": 4
},{
"resource": "/c:src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1002",
"severity": 8,
"message": "Unterminated string literal.",
"source": "ts",
"startLineNumber": 187,
"startColumn": 33,
"endLineNumber": 187,
"endColumn": 33
}]```
[error image here][2]
[1]: https://github.com/ethereum-boilerplate/ethereum-boilerplate
[2]: https://i.stack.imgur.com/EgnwO.png
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
