0

I am trying to deploy the contract using web3.js@1.2.6 enter image description hereenter image description herei have mentioned the error and code that i have typed i m stuck in line 10

  • Gee, you couldn't think of a better way than taking a photo of your screen with a camera??? I can see the background of your room there. A screenshot is just one simpler option, which is also not reccommended here, since users cannot copy/paste parts of your code into their answers. A copy/paste of your code into the question is the preferred way for posting questions here. Please do so. – goodvibration Feb 28 at 10:21
  • var Web3 = require('web3') var web3 = new Web3(new Web3.providers.HttpProvider("localhost:8545")); web3.eth.accounts code = fs.readFileSync('blockchain/voting.sol').toString() solc = require('solc') compiledCode = solc.compile(code) abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface) VotingContract = web3.eth.contract(abiDefinition) – Kaarthiga Ayyappan Feb 28 at 10:56
  • This is d code i m trying and it gives error – Kaarthiga Ayyappan Feb 28 at 10:57
  • Downvoted, pictures are not searchable, please add code. – DRP Feb 28 at 14:03
5

Obviously, I didn't replicate the code. You should try to upload code blocks that would allow us to replicate your code fast.

Nevertheless, my guess is that the error on you line 10 is caused because of web3.eth.Contract(...) expecting 2 arguments, ABI and Address of Contract, and you just gave it the ABI. Check the documentation and the following example they have here. Also, the function Contract is with a capital 'C'. Hope that helps

| improve this answer | |
1

In web3.js v0.x, use web3.eth.contract.

In web3.js v1.x, use new web3.eth.Contract.

| improve this answer | |
  • I have used it still it gives as web3.eth.contract is not a function – Kaarthiga Ayyappan Feb 28 at 10:48
  • I used web3js@1.2.6 – Kaarthiga Ayyappan Feb 28 at 11:02
  • @KaarthigaAyyappan: Good. So you can use the second option, as suggested in my answer. – goodvibration Feb 28 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.