Not able to compile truffle project

0 votes

When I try to compile, I am getting some error regarding smart contract. But I am not understanding what it is because I dont know smart contract programming. Please help. I have mentioned the details below:

$ truffle compile

Compiling ./contracts/Hello-world.sol...
Compiling ./contracts/Migrations.sol...
Compilation warnings encountered:
/home/user/truffle/contracts/Hello-world.sol:7:4: SyntaxError: Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it.
/home/user/truffle/contracts/Hello-world.sol:7:4: Warning: This declaration shadows an existing declaration.
   function Hello() {
   ^ (Relevant source part starts here and spans across multiple lines).
Compilation failed. See above.
Jan 17 in Blockchain by digger
• 27,620 points
140 views

1 answer to this question.

0 votes

Hi. If you look at the error logs, you will see the reason behind this error:

Functions are not allowed to have the same name as the contract.

So, change the contract name or the function name. If you don't wish to do this, then you will want to define this function as a constructor. 

contract abc {
...
...
...
function abc() public {
...
...
...
}
}
answered Jan 17 by Omkar
• 67,200 points

Related Questions In Blockchain

0 votes
1 answer

Not able to install truffle using npm install -g truffle

You need root access to install truffle, ...READ MORE

answered Nov 29, 2018 in Blockchain by Omkar
• 67,200 points
407 views
0 votes
1 answer

Not able to migrate contract in Truffle: Error: No network specified. Cannot determine current network

Make these entries in truffle.js file: module.exports = { ...READ MORE

answered Nov 29, 2018 in Blockchain by Omkar
• 67,200 points
97 views
0 votes
1 answer

Not able to create contracts in truffle

It seems like you have files missing that ...READ MORE

answered Dec 11, 2018 in Blockchain by Omkar
• 67,200 points
23 views
0 votes
1 answer

Not able to unbox truffle drizzle

It could be due to a broken ...READ MORE

answered Jan 9 in Blockchain by Omkar
• 67,200 points
84 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
107 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,200 points
54 views
0 votes
1 answer
0 votes
1 answer

Not able to migrate truffle project even after running testrpc

Maybe you forgot to compile the project ...READ MORE

answered Dec 11, 2018 in Blockchain by Omkar
• 67,200 points
54 views
0 votes
1 answer

Not able to start testrpc for Ethereum truffle

Hey. It seems like you already have ...READ MORE

answered Nov 28, 2018 in Blockchain by Omkar
• 67,200 points
85 views