0

I am working to build a Dapp using Ganache, Web3, and Truffle frameworks. I am unable to compile the contracts using truffle compile. I am facing an error. I want to explain you in detail what I did.

Firstly I have created a directory by using

mkdir Election

Then I changed the directory to Election using 

cd Election

Then I have used this truffle boxes to make the Dapp work simple

"truffle unbox pet-shop"

enter image description here

Then I have written a contract in the contracts directory Elections.sol enter image description here

Then I went to the migrations directory and created a file for migrating  this contract using truffle migrate. Here I am facing the issue. I am getting a while compiling. I am attaching you both the Error and the file that I have created in the migrations directory. It will be good if you could please help me asap.

This is the migrations file that will be present in the migrations directory. enter image description here

This is the Error file that I am getting when I am running

truffle migrate

enter image description here

2 Answers 2

0

I made little changes and it's working for me.

  • name your file as your contract name. i.e Election.sol
  • change function name since it shadowing the contract name.

(Truffle v5.0.9 (core: 5.0.9)
Node v10.15.2 )

0

Try one thing, Change your constructor to constructor(){} instead of function Election() public{} because there has been some changes in Solidity's new versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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