I use truffle to deploy contract to ganache network. I like to use the json file generated by the truffle in the DApp rather writing messy ABI into it. I tried the below piece of code and it gives error.
var fs = require('fs'); var publish_service_abi = JSON.parse(fs.readFileSync('./PublishService_abi.json', 'utf8')); console.log(publish_service_abi); //prints the contents of the abi var PublishServiceContractAddress = "0x0da136781e562e28fb1c0b3efc8ce9d8b4e226f2"; PublishServiceContract = await new web3.eth.Contract(publish_service_abi,PublishServiceContractAddress);
Here is the error that I get when I run the application.
Error: You must provide the json interface of the contract when instantiating a contract object. at Contract (/home/ltu/Ganache/node3/node_modules/web3-eth-contract/src/index.js:70:15) at new Contract (/home/ltu/Ganache/node3/node_modules/web3-eth/src/index.js:147:22) at initweb3 (/home/ltu/Ganache/node3/app.js:32:34)
Any help please.